combobox 消息响应 win32 sdk
下面的代码创建了一个简单的combobox,但是一点击combobox,整个程序都没有响应了,请您将下面的代码修改一下,我就想看一下想实现普通的combobox的方法.我...
下面的代码创建了一个简单的combobox,但是一点击combobox,整个程序都没有响应了,请您将下面的代码修改一下,我就想看一下想实现普通的combobox的方法.我搞了好长时间了,谢谢了.
#include <process.h>
#include <windows.h>
#include <CommCtrl.h>
#define IDC_COMBO1 100
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
default:
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;
}
int APIENTRY WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX wcex;
ZeroMemory(&wcex, sizeof wcex);
wcex.cbSize = sizeof wcex;
wcex.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
wcex.lpszMenuName = 0;
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.hInstance = hInst;
wcex.hIcon = LoadIcon(0, (LPCTSTR)IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.lpszClassName = "test";
RegisterClassEx(&wcex);
HWND hwnd = CreateWindowEx(0, ("test"), ("title"), WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_GROUP | WS_POPUP | WS_SYSMENU, 0, 0, 317, 247, 0, 0, hInst, 0);
HWND hCtrl0_8 = CreateWindowEx(0, "ComboBox", "", WS_VSCROLL|CBS_DROPDOWN | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE, 125, 114, 75, 100, hwnd, (HMENU)IDC_COMBO1, hInst, 0);
for (int i=0;i<=20;i++)
{
char tp[10];
SendMessage(hCtrl0_8,CB_ADDSTRING,0,(LPARAM)itoa(i,tp,10));
}
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg,hwnd,0,0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
} 展开
#include <process.h>
#include <windows.h>
#include <CommCtrl.h>
#define IDC_COMBO1 100
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
default:
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;
}
int APIENTRY WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX wcex;
ZeroMemory(&wcex, sizeof wcex);
wcex.cbSize = sizeof wcex;
wcex.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
wcex.lpszMenuName = 0;
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.hInstance = hInst;
wcex.hIcon = LoadIcon(0, (LPCTSTR)IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.lpszClassName = "test";
RegisterClassEx(&wcex);
HWND hwnd = CreateWindowEx(0, ("test"), ("title"), WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_GROUP | WS_POPUP | WS_SYSMENU, 0, 0, 317, 247, 0, 0, hInst, 0);
HWND hCtrl0_8 = CreateWindowEx(0, "ComboBox", "", WS_VSCROLL|CBS_DROPDOWN | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE, 125, 114, 75, 100, hwnd, (HMENU)IDC_COMBO1, hInst, 0);
for (int i=0;i<=20;i++)
{
char tp[10];
SendMessage(hCtrl0_8,CB_ADDSTRING,0,(LPARAM)itoa(i,tp,10));
}
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg,hwnd,0,0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询