- 60 名前:デフォルトの名無しさん mailto:sage [2009/12/24(木) 14:51:09 ]
- WindowsAPIが混じっているのですがご了承ください。
以下、strの宣言が悪いといってコンパイルエラーになります。 LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_PAINT: HDC hdc; PAINTSTRUCT paint; char *str = "猫でもわかるプログラミング"; hdc = BeginPaint(hWnd, &paint); TextOut(hdc, 10, 10, (LPCSTR)str, strlen(str)); EndPaint(hWnd, &paint); break; 以下のように、{を追加するとエラーが出なくなります。どうして{が必要なのでしょうか? LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_PAINT: { ←★追加 HDC hdc; PAINTSTRUCT paint; char *str = "猫でもわかるプログラミング"; hdc = BeginPaint(hWnd, &paint); TextOut(hdc, 10, 10, (LPCSTR)str, strlen(str)); EndPaint(hWnd, &paint); break; } ←★追加
|

|