Array
(
)

WinMain()

Bigtama
   - 28 fev 2004

ae, eu baxei o BORLAND C++ Builder X (que pra mim ta sendo uma bosta) e comecei a aprende a programa, dai quando eu fui usa o exemplo de um livro eu digitei isso:



Citação:


#include <windows.h>
LRESULT CALLBACK WindowFunc (HWND, UINT, WPARAM, LPARAM):
char szWinName[] = ´MinhaJan´;
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASS wcl;
wcl.hInstance = hThisInst;
wcl.lpszClassName = szWinName;
wcl.lpfnWndProc = WindowFunc;
wcl.style = 0;

wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);

wcl.hCursor = LoadCursor(NULL, IDC_ARROW);

wcl.lpszMenuName = NULL;

wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;

wcl.hbrBackground= (HBRUSH) GetStockObject(WHITE_BRUSH);
if (!RegisterClass (&wcl)) return 0;

hwnd = CreateWindow(
szWinName,
´Tsuki - Hanime Center S.a.´,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
HWND_DESKTOP,
NULL,
hThisInst,
NULL
);

ShowWindow(hwnd, nWinMode);
UpdateWindow(hwnd);
While (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK WindowFunc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_DESTROY:
PostQuitMessage(0);
break;
default;
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}




e apareceu os seguintes erros:


Citação:



bcc32 -D_DEBUG -g100 -j25 -Od -r- -k -y -v -vi- -tWC -c -IC:\CBuilderX\include -o´C:\Documents and Settings\Administrador\cbproject\ConsoleApp1\windows\Debug_Build\untitled.obj´ untitled.cpp
Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland
untitled.cpp:
´untitled.cpp´: E2275 { expected in function __stdcall WindowFunc(HWND__ *,unsigned int,unsigned int,long) at line 9
´untitled.cpp´: E2040 Declaration terminated incorrectly at line 9
´untitled.cpp´: E2451 Undefined symbol ´szWinName´ in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) at line 19
´untitled.cpp´: E2268 Call to undefined function ´While´ in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) at line 51
´untitled.cpp´: E2379 Statement missing ; in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) at line 52
´untitled.cpp´: W8070 Function should return a value in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) at line 57
´untitled.cpp´: W8057 Parameter ´hPrevInst´ is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) at line 57
´untitled.cpp´: W8057 Parameter ´lpszArgs´ is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) at line 57
´untitled.cpp´: E2171 Body has already been defined for function ´__stdcall WindowFunc(HWND__ *,unsigned int,unsigned int,long)´ at line 60
´untitled.cpp´: E2451 Undefined symbol ´message´ in function __stdcall WindowFunc(HWND__ *,unsigned int,unsigned int,long) at line 61
´untitled.cpp´: E2041 Incorrect use of default in function __stdcall WindowFunc(HWND__ *,unsigned int,unsigned int,long) at line 65
´untitled.cpp´: E2451 Undefined symbol ´hwnd´ in function __stdcall WindowFunc(HWND__ *,unsigned int,unsigned int,long) at line 66
´untitled.cpp´: E2451 Undefined symbol ´wParam´ in function __stdcall WindowFunc(HWND__ *,unsigned int,unsigned int,long) at line 66
´untitled.cpp´: E2451 Undefined symbol ´lParam´ in function __stdcall WindowFunc(HWND__ *,unsigned int,unsigned int,long) at line 66
*** 11 errors in Compile ***
BCC32 exited with error code: 1
Build cancelled due to errors






O QUE DIABOS QEU DE ERRADO, NO LIVRO TA TUDO CERTO.

OBRIGADO A TODOS.


Delves
   - 29 mar 2004

Não conheço o C++Builder X. Mas podemos considerar algumas coisas.

O livro é referente ao C++Builder X? Esse compilador possui o cabeçalho windows.h?

Eu sei que o BCB não usa esse cabeçalho. Se você quiser fazer esse código acima funcionar no C++Builder (até o 6) deverá incluir o cabeçalho vcl.h e não o windows.h.

Mas como falei, não conheco o C++Builder X.

Delves


Kao00
   - 31 mar 2004

Isso ai é o código de uma Windows Application. Na hora de compilar, vc não pode compilar como Console Application senão dá erro mesmo. Olha direitinho ai no seu compilador, na hora que vc vai criar um projeto novo. Deve ter alguma coisa de Windows Application.