//先创建了一个panel
hwnd_panel = CreateWindowEx(0, "static", "panel",
WS_CHILD | WS_VISIBLE | SS_BITMAP, // | SS_NOTIFY | WS_BORDER
650, 56, 681, 660,
hwnd_frame, (HMENU)id_panel, g_hInstance, NULL);
//然后将一个滑块放到这个 panel上:
hwnd_s_quality = CreateWindowEx(0, "msctls_trackbar32", "",
WS_CHILD | WS_VISIBLE | TBS_TOOLTIPS | TBS_NOTICKS | TBS_HORZ ,
97, // xpos
50, // ypos
88, //width
25, //height
hwnd_panel, (HMENU)id_s_quality, g_hInstance, NULL) ;
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) /* handle the messages */
{
case WM_HSCROLL:
{
printf("----------------case WM_HSCROLL:\n"); //拖动滑块的时候,接收不到消息
break;
}
}
}
怎么设置,才能正常接收到 WM_HSCROLL 呢?
6 个解决方案
#1
我刚刚试了一下,如果把一个按钮嵌入到一个"static"控件中后,点击按钮主窗口也接收不到WM_COMMAND
新手一个,我。
新手一个,我。
#2
int WINAPI WinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
while(GetMessage(&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
// 仅能在这里接收到消息了..............
}
}
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
while(GetMessage(&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
// 仅能在这里接收到消息了..............
}
}
#3
你这个是sdk 还是mfc啊?
是sdk 的话要在wndclass的function 赋值WindowProcedure
是sdk 的话要在wndclass的function 赋值WindowProcedure
#4
用 codeblocks 写的, sdk ?
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);
#5
我把两个按钮放在一个[static]控件中 (也就是说两个按钮的父窗口是一个 [static]控件 ,这样的话,点击按钮,就接收不到 WM_COMMAND
如果把两个按钮直接放在 frame中 (父窗口是一个 frame),这样就能正常的接收 WM_COMMAND
#6
还是在csdn上找到解决办法了:
http://bbs.csdn.net/topics/340161335
SetWindowLong(HWND_指定的父窗口,GWL_WNDPROC,(LONG)myProcedure);
然后:
LRESULT CALLBACK myProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) /* handle the messages */
{
case WM_COMMAND:
}
}
就行了。
http://bbs.csdn.net/topics/340161335
SetWindowLong(HWND_指定的父窗口,GWL_WNDPROC,(LONG)myProcedure);
然后:
LRESULT CALLBACK myProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) /* handle the messages */
{
case WM_COMMAND:
}
}
就行了。
#1
我刚刚试了一下,如果把一个按钮嵌入到一个"static"控件中后,点击按钮主窗口也接收不到WM_COMMAND
新手一个,我。
新手一个,我。
#2
int WINAPI WinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
while(GetMessage(&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
// 仅能在这里接收到消息了..............
}
}
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
while(GetMessage(&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
// 仅能在这里接收到消息了..............
}
}
#3
你这个是sdk 还是mfc啊?
是sdk 的话要在wndclass的function 赋值WindowProcedure
是sdk 的话要在wndclass的function 赋值WindowProcedure
#4
用 codeblocks 写的, sdk ?
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);
#5
我把两个按钮放在一个[static]控件中 (也就是说两个按钮的父窗口是一个 [static]控件 ,这样的话,点击按钮,就接收不到 WM_COMMAND
如果把两个按钮直接放在 frame中 (父窗口是一个 frame),这样就能正常的接收 WM_COMMAND
#6
还是在csdn上找到解决办法了:
http://bbs.csdn.net/topics/340161335
SetWindowLong(HWND_指定的父窗口,GWL_WNDPROC,(LONG)myProcedure);
然后:
LRESULT CALLBACK myProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) /* handle the messages */
{
case WM_COMMAND:
}
}
就行了。
http://bbs.csdn.net/topics/340161335
SetWindowLong(HWND_指定的父窗口,GWL_WNDPROC,(LONG)myProcedure);
然后:
LRESULT CALLBACK myProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) /* handle the messages */
{
case WM_COMMAND:
}
}
就行了。