Beginner VC, there is a most basic problem! ^

xiaoxiao2021-03-06  48

#include #include #include

Long WinAPI WndProc (HWND HWND, UINT IMESSAGE, UINT WPARAM, Long LParam); Bool InitWindowsClass (Hinstance Hinstance); Bool InitWindows (Hinstance Hinstance, Int ncmdshow); hwnd hwndmain

// Main function int winapi WinMain (Hinstance Hinstance, Hinstance Hprevinstance, LPSTR LPCMDLINE, INT NCMDSHOW)

{MSG Message; if (InitWindowsClass (hInstance)!) Return FALSE; if (InitWindows (hInstance, nCmdShow)!) Return FALSE; while (GetMessage (& Message, 0,0,0)) {TranslateMessage (& Message); DispatchMessage (& Message } Return message.wparam;}

LONG WINAPI WNDPROC (HWND HWND, UINT IMESSAGE, UINT WPARAM, long lparam) {HDC HDC; Hbrush Hbrush; HPEN HPEN; PAINTSTRUCT PTSTR

Point Points [6] = {{100, 212}, {70, 250}, {130, 250}, {130, 227}, {100, 212}}; switch (iMessage) {case wm_paint: hdc = beginpaint (hwnd, & ptstr); hpen = (hpen) GetStockObject (NULL_PEN); SelectObject (hDC, hPen); hBrush = (HBRUSH) GetStockObject (BLACK_BRUSH); SelectObject (hDC, hBrush); LineTo (hDC, 50,50); DeleteObject (hPen); hPen = CreatePen (PS_SOLID, 2 , RGB (255, 0)); SELECTOBJECT (HDC, HPEN);

LineTo (hDC, 150,50); LineTo (hDC, 100,137); LineTo (hDC, 50,50); Polyline (hDC, points, 6); Arc (hDC, 63,137,138,212,100,137,100,137); Pie (hDC, 213,137,288,212,240,137,260,137); Rectangle ( HDC, 213, 212, 287, 250); RoundRect (HDC, 213, 100, 287, 137, 20, 20); DeleteObject (HPEN); deleteObject (Hbrush); EndPaint (hwnd, & ptstr); Return 0;

Case WM_DESTROY: PostquitMessage (0); Return 0; Default: Return (DEFWINDOWPROC (HWND, IMESSAGE, WPARAM, LPARAM);}}

BOOL InitWindows (HINSTANCE hInstance, int nCmdShow) {HWND hWnd; hWnd = CreateWindow ( "WinFill", "filled sample program", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (hWnd! ) return FALSE; hWndMain = hWnd; ShowWindow (hWnd, nCmdShow), UpdateWindow (hWnd); return TRUE;} BOOL InitWindowsClass (hINSTANCE hInstance) {WNDCLASS WndClass; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hbrBackground = (HBRUSH) (GetStockObject (WHITE_BRUSH)); WndClass.hCursor = LoadCursor (NULL, IDC_ARROW); WndClass.hIcon = LoadIcon (NULL, "END"); WndClass.hInstance = hInstance; WndClass.lpfnWndProc = WndProc; WndClass.lpszClassName = NULL; WNDCLASS.LPSZMENUNUNAME = NULL; WNDCLASS.Style = CS_HREDRAW | CS_VREDRAW; RETURN RegisterClass (& WNDCLASS);

************************************************ this is Just studying a code to be knocked in the book, I can make sure that there is no problem with the book, but when debugging on your computer, it is always a problem. The mistake is as follows: -------------------- Configuration: CPP1 - Win32 Debug -------------------- LINKING ... libcd.lib (CRT0.Obj): Error LNK2001: Unresolved External Symbol _mainDebug / cpp1.exe: Fatal Error LNK1120: 1 Unresolved ExternalSerror Executing Link.exe.

CPP1.EXE - 2 Error (s), 0 Warning (s) I have already got two days, there is no prawn to save the younger brother! There is no way to understand what is going on! I also knocked on a similar program before he had the same problem! I have started to suspect that it is no problem with my system! There is no way, thank you!

转载请注明原文地址:https://www.9cbs.com/read-80338.html

New Post(0)