Napisem program,pokrenem ga i kad zavrsi sa izvrsavanjem prozor mi je i dalje otvoren, samo u gornjem levom cosku prozora pise inactive. Pomocu koje komande bih mogao kad je napisem da se po zavrsetku izvrsavanja programa prozor zatvoriti?
Kako da zatvorim prozor?
Zaključano
Zakačeno
Mislim neka funkcija close window ili nesto na taj fazon. I ako nesto znaci koristim burland turbo c/c++ 4.5(iz 1995-e).
Svaki prozor u windowsu koristi window proceduru (funkciju koja procesuira GUI poruke) i ona mora da se napise tako da barata i sa zatvaranjem.
Izpod je sablon GUI Aplikacije koju generise Code::Blocks pa pogledaj "WindowProcedure".
PS Nadam se da si mislio na GUI app a ne na zatvaranje prozora command prompta
Izpod je sablon GUI Aplikacije koju generise Code::Blocks pa pogledaj "WindowProcedure".
PS Nadam se da si mislio na GUI app a ne na zatvaranje prozora command prompta
Code:
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "CodeBlocksWindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Code::Blocks Template Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "CodeBlocksWindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Code::Blocks Template Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
Potpis
HomePage http://www.eurora3d.com
Tako je-mislio sam na GUI aplikaciju,posto se dos prozor svakako automatski zatvara. Probao sam ovaj kod ali mi prijavljuje sledece greske:{
Compiling NONAME04.CPP:
Error NONAME04.CPP 17: Undefined symbol 'WNDCLASSEX' in function pascal WinMain(unsigned int,unsigned int,char *,int)
Error NONAME04.CPP 17: Statement missing ; in function pascal WinMain(unsigned int,unsigned int,char *,int)
Error NONAME04.CPP 20: Undefined symbol 'wincl' in function pascal WinMain(unsigned int,unsigned int,char *,int)
Error NONAME04.CPP 24: Not an allowed type in function pascal WinMain(unsigned int,unsigned int,char *,int)
Error NONAME04.CPP 37: Call to undefined function 'RegisterClassEx' in function pascal WinMain(unsigned int,unsigned int,char *,int)
Warning NONAME04.CPP 70: Parameter 'hPrevInstance' is never used in function pascal WinMain(unsigned int,unsigned int,char *,int)
Warning NONAME04.CPP 70: Parameter 'lpszArgument' is never used in function pascal WinMain(unsigned int,unsigned int,char *,int)}
a posto nikad nisam pravio nista sto ima veze sa ovim ne znam nista sta znaci, kako bih znao ispraviti ove greske?
Compiling NONAME04.CPP:
Error NONAME04.CPP 17: Undefined symbol 'WNDCLASSEX' in function pascal WinMain(unsigned int,unsigned int,char *,int)
Error NONAME04.CPP 17: Statement missing ; in function pascal WinMain(unsigned int,unsigned int,char *,int)
Error NONAME04.CPP 20: Undefined symbol 'wincl' in function pascal WinMain(unsigned int,unsigned int,char *,int)
Error NONAME04.CPP 24: Not an allowed type in function pascal WinMain(unsigned int,unsigned int,char *,int)
Error NONAME04.CPP 37: Call to undefined function 'RegisterClassEx' in function pascal WinMain(unsigned int,unsigned int,char *,int)
Warning NONAME04.CPP 70: Parameter 'hPrevInstance' is never used in function pascal WinMain(unsigned int,unsigned int,char *,int)
Warning NONAME04.CPP 70: Parameter 'lpszArgument' is never used in function pascal WinMain(unsigned int,unsigned int,char *,int)}
a posto nikad nisam pravio nista sto ima veze sa ovim ne znam nista sta znaci, kako bih znao ispraviti ove greske?
Resi prvo ovaj problem, ostali ce verovatno nestati:
ovo je mnogo bitno Statement missing ;
...
Citat:
Error NONAME04.CPP 17: Statement missing ; in function pascal WinMain(unsigned int,unsigned int,char *,int)
ovo je mnogo bitno Statement missing ;
...
Jesi li ukljucio windows.h ?
#include <windows.h>
Sve definicije moraju da se inkluduju pre upotrebe.
@Ovo Statement missing ; u liniji 17 je zato to ne moze da nadje definiciju strukture WNDCLASSEX u istom redu.
#include <windows.h>
Sve definicije moraju da se inkluduju pre upotrebe.
@Ovo Statement missing ; u liniji 17 je zato to ne moze da nadje definiciju strukture WNDCLASSEX u istom redu.
Potpis
HomePage http://www.eurora3d.com
Ne fali mi #include<windows.h>
Jel provereno da li ovaj kod radi uopste?
Jel provereno da li ovaj kod radi uopste?
Pa naravno da radi
. To je sablon za Win GUI app koji pravi Code::Blocks razvojno okruzenje.
Kod moze da se kompajlira sa MS VC++ i MinGw kompajlerima (sigurno).
Taj program je kao
sablon za command line programe.
Preporuka , promeni kompajler ili pretrazi fajlove iz kompajler include foldera da vidis gde je definisana WNDCLASSEX. Treba da bude u WINUSER.H . Ako jeste ukljuci i taj header fajl.
Pozdrav
Kod moze da se kompajlira sa MS VC++ i MinGw kompajlerima (sigurno).
Taj program je kao
Code:
int main()
{
return 0;
}
int main()
{
return 0;
}
sablon za command line programe.
Preporuka , promeni kompajler ili pretrazi fajlove iz kompajler include foldera da vidis gde je definisana WNDCLASSEX. Treba da bude u WINUSER.H . Ako jeste ukljuci i taj header fajl.
Pozdrav
Potpis
HomePage http://www.eurora3d.com