好的,首先这是家庭作业,但我们的老师鼓励我们超越他实际给我们的作业。所以我想学习如何添加常用对话框。我选择使用组合框。
问题是..我完全不知道从哪里开始。我已经用谷歌搜索了它并在没有帮助的情况下浏览了第一页半,所以我在这里发布:)。任务是做一些简单的事情,比如显示我的名字和画一些省略号,现在我想添加一个组合框..
这是我的代码。
/*------------------------------------------------------------------------
Name: Jesse Moreland
Class: CST 238 GUI
Lab 2
---------------------------------------------------------------------------*/
#include <windows.h>
#include <WinUser.h>
#include <string>
using std::string;
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpszCmdParam, int nCmdShow)
{
static char szAppName[] = "ErrorSample";
HWND hwnd;
HWND comboBox;
MSG msg; // Look how this struct is defined-see help/class notes NOW
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = static_cast<HBRUSH>(GetStockObject (WHITE_BRUSH));
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL, MAKEINTRESOURCE(IDI_ERROR));
RegisterClassEx (&wndclass);
// PlaySound("C:\\Windows\\winsxs\\x86_microsoft-windows-speech-userexperience_31bf3856ad364e35_6.1.7601.17514_none_1e1159f6aa0eb8c7\\Speech Off.wav",NULL, SND_FILENAME);
hwnd = CreateWindow (szAppName, // window class name
"Jesse Moreland LAB 2 - Press Left or Right Mouse Button", // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters
ShowWindow (hwnd, nCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
RECT size;
char * summer = "SUMMER IS COMING SOON!";
char * leftOrRight = "Press Left or Right Mouse Button to make selection";
switch (message)
{
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps);
GetClientRect (hwnd, &rect);
GetWindowRect(hwnd, &size);
HPEN hPenOld;
//Draw ellipse
HPEN hEllipsePen;
COLORREF qEllipseColor;
qEllipseColor = RGB(0, 0, 255);
hEllipsePen = CreatePen(PS_SOLID, 3, qEllipseColor);
hPenOld =(HPEN)SelectObject(hdc, hEllipsePen);
Arc(hdc, 40, 40, 160, 80, 0, 0, 0, 0);
Arc(hdc, 50, 50, 180, 60, 0, 0, 0, 0);
SelectObject(hdc, hPenOld);
DeleteObject(hEllipsePen);
TextOut(hdc, 0, 0, summer, strlen(summer));
TextOut(hdc, 0, 20, leftOrRight, strlen(leftOrRight));
EndPaint (hwnd, &ps);
return 0;
case WM_LBUTTONDOWN:
return 0;
case WM_RBUTTONDOWN:
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}
我将把命令放在哪里来制作组合框?