|
아래에 간단한 winmain code 올렸습니다. hellowin.cpp 라고 하면...
저 아래에서 유사한 질문을 올렸습니다. 개박살님께서 친절히 답해주셨지만, 제 무공이
부족한 탓인지 그 수가 펼쳐지지가 않습니다. 그래서 다시 정리해서 질문을 올립니다..
모든 파일을 다 닫고 난뒤에, hwllowin.cpp를 open하였습니다. 그랬더니,
'컴파일을 하고 런을 할 수 있게 프로젝트를 만들꺼냐 ? ' 라고 묻는 창이 나와서
'Yes'를 선택하였습니다. 요 상태에서 컴파일, 런을 하면 잘 돌아갑니다.
여기에 폼을 하나 붙이려고 합니다. 제가 하려는 일을 극으로 단순화 시켜서
hellowin.cpp 에 있는 임시 변수 temp_var (100을 넣었습니다.WM_CREATE에서)를
폼쪽에 있는 Label에 표시하게 하려고 합니다.
메뉴에서 File | New Form 을 선택하여서 폼을 하나 만들었습니다.
프로젝트 매니저로 보면 'Unit1.cpp Form'이 Hellowin.exe아래에 위치하고 있습니다.
이 상태에서 런을 시키면 처음에 hellowin.cpp만을 돌릴때와 같은 결과가 나옵니다.
방금 만든 폼은 활성화되지 않습니다.
위에서 개박살님께서 말씀하신 것처럼 메뉴에서 Project | Options | Forms 에서
Available forms에 있는 Form1 을 Auto-create forms 쪽으로 옮겼습니다. 그랬더니
이제까지는 빈칸으로 있던 'Main form'란에 Form1 이 등록이 됩니다.
여기서 OK 를 누르면...
'Call to Application->CreateForm is missing or incorrect'
라는 에러메세지가 나옵니다. 에러메세지 창에 같이 있는 'Help'를 눌러 읽어보면
The project's target could not be found in file 'file'?
The project's target is commonly WinMain or DllEntryPoint
You are trying to build a project that is missing the WinMain or DllEntryPoint. C++ Builder projects generally consist of a makefile (.BPR or .BPK) and a .CPP project source file. For Windows GUI applications, the project source file includes a WinMain as the Entry point. For a DLL, the entry point is DllEntryPoint and for a console application the entry point is main.
이런 말이 나옵니다. winmain이 없는 프로젝트를 컴파일 하려했다나.. hellowin.cpp에
winmain이 있는데도 말입니다.
이게 도대체 어찌돌아가는 상황인지. 어찌 해결해야 하는지..
다시 한번 무림초중고수님들의 비법을 보여주시길 부탁드립니다..
아래에는 hellowin.cpp 코드입니다.
/*------------------------------------------------------------
HELLOWIN.cpp -- Displays "Hello, Windows 95!" in client area
(c) Charles Petzold, 1996
------------------------------------------------------------*/
#include <windows.h>
#include <wingdi.h>
#include <mmsystem.h>
int temp_var ;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static char szAppName[] = "HelloWin" ;
HWND hwnd ;
MSG msg ;
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 = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION) ;
RegisterClassEx (&wndclass) ;
hwnd = CreateWindow (szAppName, // window class name
"The Hello Program", // 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, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
switch (iMsg)
{
case WM_CREATE :
temp_var = 100 ;
return 0 ;
case WM_PAINT :
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
DrawText (hdc, "Hello, Windows 95!", -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
|