case WM_CREATE:
{
/* The window is being created. Create our button
* window now. */
TEXTMETRIC tm; /* First we use the system fixed font size to choose
* a nice button size. */
hdc = GetDC (hwnd);
SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
GetTextMetrics (hdc, &tm);
cx = tm.tmAveCharWidth * 30;
cy = (tm.tmHeight + tm.tmExternalLeading) * 2;
ReleaseDC (hwnd, hdc); /* Now create the button */
hwndButton = CreateWindow (
"button",/* Builtin button class */
"Click Here",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 0, cx, cy,
hwnd,/* Parent is this window. */
(HMENU) 1,/* Control ID: 1 */
((LPCREATESTRUCT) lParam)->hInstance,
NULL); /*创建一个编辑框 */
hwndEdit = CreateWindow(TEXT("Edit"),
NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT,
0,0,100,20,
hwnd,
(HMENU)ID_EDIT,
((LPCREATESTRUCT)lParam)->hInstance,
NULL); //PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
break; return 0;
break;
} case WM_COMMAND:
{
/* Check the control ID, notification code and
* control handle to see if this is a button click
* message from our child button. */
if (LOWORD(wParam) == 1 &&
HIWORD(wParam) == BN_CLICKED &&
(HWND) lParam == hwndButton)
{
char *pBuf = "Connecting..."; /* 取出来编辑框里面的内容 */ CHAR strText[1024]= " ";
GetWindowText(hwndEdit, strText, 100); MessageBox(NULL, strText, "文本框里的内容是: ",0);//每次获取都是空
//memcpy(g_Databuf, pBuf, strlen(pBuf));
InvalidateRect(hwnd,NULL,TRUE);
UpdateWindow(hwnd);
}
return 0;
break;
}
{
/* The window is being created. Create our button
* window now. */
TEXTMETRIC tm; /* First we use the system fixed font size to choose
* a nice button size. */
hdc = GetDC (hwnd);
SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
GetTextMetrics (hdc, &tm);
cx = tm.tmAveCharWidth * 30;
cy = (tm.tmHeight + tm.tmExternalLeading) * 2;
ReleaseDC (hwnd, hdc); /* Now create the button */
hwndButton = CreateWindow (
"button",/* Builtin button class */
"Click Here",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 0, cx, cy,
hwnd,/* Parent is this window. */
(HMENU) 1,/* Control ID: 1 */
((LPCREATESTRUCT) lParam)->hInstance,
NULL); /*创建一个编辑框 */
hwndEdit = CreateWindow(TEXT("Edit"),
NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT,
0,0,100,20,
hwnd,
(HMENU)ID_EDIT,
((LPCREATESTRUCT)lParam)->hInstance,
NULL); //PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
break; return 0;
break;
} case WM_COMMAND:
{
/* Check the control ID, notification code and
* control handle to see if this is a button click
* message from our child button. */
if (LOWORD(wParam) == 1 &&
HIWORD(wParam) == BN_CLICKED &&
(HWND) lParam == hwndButton)
{
char *pBuf = "Connecting..."; /* 取出来编辑框里面的内容 */ CHAR strText[1024]= " ";
GetWindowText(hwndEdit, strText, 100); MessageBox(NULL, strText, "文本框里的内容是: ",0);//每次获取都是空
//memcpy(g_Databuf, pBuf, strlen(pBuf));
InvalidateRect(hwnd,NULL,TRUE);
UpdateWindow(hwnd);
}
return 0;
break;
}
解决方案 »
- windows ULONG 重复定义 问题 error C2371: 'ULONG' : redefinition; different basic type
- odbc 操作单个DBF数据表
- 问一个弱智的问题...如果用VC#写的界面,那么里面函数的实现也要用C#写吗 ?
- 关于设置后台线程优先级。大家帮我拿拿主意。
- 一个关于弹出式菜单的问题
- 知道dll的HINSTANCE,怎么知道dll的名字?
- 圆形带图片的按钮如何实现
- 怎样写一个License的控制插件?主要思路是什么呀?请大家指教!
- 大家节日好!!!!!!!!来者有分!!
- 如何定位我加的对话框工具栏?
- 菜鸟提问!关于学习孙鑫的VC++视频第5课的难题。
- CDialg类的问题?
把控件的值传给对应的变量。 可能需要这个^_^