当前位置: 技术问答>linux和unix
LINUX 使用libx编写界面 如何创建Widget 实例的问题,请高手指点
来源: 互联网 发布时间:2016-06-10
本文导语: 我使用libx库创建拉一个窗口,然后我通过这个窗口handle 得到它的一个Widget,程序在运行到 Widget xtwidget = XtWindowToWidget(display, win)时发生错误了,提示:“Error: Couldn't find per display information“。请高手帮看看是什...
我使用libx库创建拉一个窗口,然后我通过这个窗口handle 得到它的一个Widget,程序在运行到 Widget xtwidget = XtWindowToWidget(display, win)时发生错误了,提示:“Error: Couldn't find per display information“。请高手帮看看是什么地方问题,感觉应该是display参数有问题,我gdb进去又能看到display是有值的,且跟我之前通过XOpenDisplay打开的一样, 具体代码如下:
#include
#include
#include
#include
#include
#include
//#include "dsimple.h"
#include
#include
using namespace std;
static Window selectWindow(Display* dpy);
GC gc;
Display *display;
int screen;
Window win, root;
unsigned long white_pixel, black_pixel;
int x, y, bidon, i = 0;
int main()
{
if ((display = XOpenDisplay (":0")) == NULL)
{
fprintf (stderr, "Can't open Displayn");
return 1;
}
gc = DefaultGC (display, screen);
screen = DefaultScreen (display);
root = RootWindow (display, screen);
white_pixel = WhitePixel (display, screen);
black_pixel = BlackPixel (display, screen);
win = XCreateSimpleWindow (display, root,
1, 1, 1000, 800, 5, black_pixel, white_pixel);
// win = Select_Window(display);
Widget xtwidget = XtWindowToWidget(display, win);
if (!xtwidget)
{
cout
#include
#include
#include
#include
#include
#include
//#include "dsimple.h"
#include
#include
using namespace std;
static Window selectWindow(Display* dpy);
GC gc;
Display *display;
int screen;
Window win, root;
unsigned long white_pixel, black_pixel;
int x, y, bidon, i = 0;
int main()
{
if ((display = XOpenDisplay (":0")) == NULL)
{
fprintf (stderr, "Can't open Displayn");
return 1;
}
gc = DefaultGC (display, screen);
screen = DefaultScreen (display);
root = RootWindow (display, screen);
white_pixel = WhitePixel (display, screen);
black_pixel = BlackPixel (display, screen);
win = XCreateSimpleWindow (display, root,
1, 1, 1000, 800, 5, black_pixel, white_pixel);
// win = Select_Window(display);
Widget xtwidget = XtWindowToWidget(display, win);
if (!xtwidget)
{
cout