|
dev.gamez.lv Latvian Game Developers Community
|
View previous topic :: View next topic |
Author |
Message |
Angel
Joined: 02 Jan 2005 Posts: 113 Location: Latvija
|
Posted: Mon Mar 21, 2005 5:31 pm Post subject: |
|
Naakamais "iespiediens" zem nosaukuma paliidzat.
Nu redziet Code: |
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
sWindow* window = (sWindow*)(GetWindowLong(hWnd,GWL_USERDATA));
switch(uMsg){
/* case WM_CLOSE:
DestroyWindow(window->hWnd);
break;*/
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
|
ja izkomentē case WM_CLOSE ... , tad vinsh uzmet
Test.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
Please tell Microsoft about this problem.
Gan jau sapratiisiet kas tas ir
bet ja to nelieto, probleemu nav. Kaads vareetu pateikt kapeec. (Vienkārši intereses pēc...) _________________
|
|
Back to top |
|
|
GiGa Indago Uzvarētājs
Joined: 25 Sep 2003 Posts: 887
|
Posted: Mon Mar 21, 2005 7:39 pm Post subject: |
|
Nepateikshu konkreeti kas, bet, aciimredzot, DefWindowProc kaut kaa nepareizi apstraadaa WM_CLOSE message'u - visdriizaak tas balstaas uz kaadu pienjeemumu, kuru tu, radot savu logu, esi paarkaapis. Piemeeram, varbuut vinsh domaa, ka tu obligaati izsauksi DestroyWindow pats :)
P.S. Tieshaam - taisi katram jautaajumam savu threadu luudzu
EDIT: tomeer noleemu izjust jaunaas mod'a speejas un izdariiju to tavaa vietaa _________________
|
|
Back to top |
|
|
chaosman
Joined: 28 Oct 2003 Posts: 64 Location: Rīga
|
Posted: Mon Mar 21, 2005 8:36 pm Post subject: |
|
Droshi vien vaina buus tajaa pointerii 'window', shitais izskataas aizdomiigi: window->hWnd.
A kas notiek ja to kodu atstaaj izkomenteetu? Logs neveraas ciet? (nedaudz piemirsusies man taa msg apstraade). Lai nu kaa, bet debugeris un http://msdn.microsoft.com paliidzees.
Giga - ja pareizi saparotu, tad topika autoram probleema ir tieshi tad, ja DefWindowProc netiek izsaukta. |
|
Back to top |
|
|
Angel
Joined: 02 Jan 2005 Posts: 113 Location: Latvija
|
Posted: Mon Mar 21, 2005 9:39 pm Post subject: |
|
Kaa jau teicu, ja tas paliek izkomenteets wiss straadaa oki doki, tikai interese kapeec nestraadaa. Un tas "window->hWnd" ir tikai tapeec, ka vienkaarshi winsh nevar dabuut aaraa window.
Ja
(sWindow*)(GetWindowLong(hWnd,GWL_USERDATA))
aizstaaj ar
(sWindow)(GetWindowLong(hWnd,GWL_USERDATA))
: ERROR :D
thx GiGa vnk nezinaaju kaa to nosaukt _________________
|
|
Back to top |
|
|
GiGa Indago Uzvarētājs
Joined: 25 Sep 2003 Posts: 887
|
Posted: Mon Mar 21, 2005 9:54 pm Post subject: |
|
Hmm, pirmajaa postaa tu skaidri un gaishi pasaki:
Quote: |
ja izkomentē case WM_CLOSE ... , tad vinsh uzmet
Test.exe has encountered a problem and needs to close.
|
Bet nu labi, ja izkomentee noziimee nekomentee _________________
|
|
Back to top |
|
|
Angel
Joined: 02 Jan 2005 Posts: 113 Location: Latvija
|
Posted: Mon Mar 21, 2005 11:09 pm Post subject: |
|
Ups, laikam paarrakstiijos _________________
|
|
Back to top |
|
|
Vecais_Dumais_Laacis Guru
Joined: 29 Jan 2004 Posts: 800
|
Posted: Mon Mar 21, 2005 11:47 pm Post subject: |
|
uztaisi debugu/paarbaudi vai userdata gadienaa tev neatgriezh 0 _________________ ...un ja bites buutu laachi... |
|
Back to top |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Tue Mar 22, 2005 8:37 am Post subject: |
|
Un parādi kodu, kur uzstādi to userdata, moš tur esi kautko samuhļījis. |
|
Back to top |
|
|
Angel
Joined: 02 Jan 2005 Posts: 113 Location: Latvija
|
Posted: Tue Mar 22, 2005 3:25 pm Post subject: |
|
Koods buus te:
Code: |
#include <windows.h>
struct sWindow{
int width, height;
HWND hWnd;
char* className;
char* title;
};
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
sWindow* window = (sWindow*)(GetWindowLong(hWnd,GWL_USERDATA));
switch(uMsg){
/* case WM_CLOSE:
DestroyWindow(window->hWnd);
break;*/
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){
sWindow window;
window.height = 200;
window.width = 200;
window.className = "CLASS NAME";
window.title = "TITLE";
WNDCLASSEX wc;
wc.cbClsExtra = 0;
wc.cbSize = sizeof(wc);
wc.cbWndExtra = 0;
wc.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL,IDI_WINLOGO);
wc.hIconSm = LoadIcon(NULL,IDI_WINLOGO);
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
wc.lpszClassName= window.className;
wc.lpszMenuName = NULL;
wc.style = 0;
if(!RegisterClassEx(&wc)){
MessageBox(NULL,"Cant register window class", "ERROR", MB_ICONERROR | MB_OK);
return 0;
}
window.hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,window.className,window.title,WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT, window.width,window.height,
NULL,NULL,hInstance,NULL);
if(window.hWnd==NULL){
MessageBox(NULL,"Cant create window", "ERROR", MB_OK | MB_ICONERROR);
return false;
}
ShowWindow(window.hWnd,nShowCmd);
UpdateWindow(window.hWnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0)>0){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
} |
_________________
|
|
Back to top |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Tue Mar 22, 2005 3:42 pm Post subject: |
|
Un kas tad šis par brīnumu:
Un kur ir SetWindowLong( hWnd, GWL_USERDATA, ...); ?
Tev takš tas window iekš WndProc vienmēr būs NULL!!
Vai vispār pats zini, ko dara GetWindowLong() fja? |
|
Back to top |
|
|
Angel
Joined: 02 Jan 2005 Posts: 113 Location: Latvija
|
Posted: Tue Mar 22, 2005 6:05 pm Post subject: |
|
tikai ljoti aptuveni
taatad vina size jaaliek pie extra, ja???
un veel jaapieraksta SetWindowLong(...)
P.S. Funkciju GetWindowLong(...) es redzeeju NeHe sourcee, bet tur taada Set........ nebija un arii cbClsExtra nee. Kaads vareetu pateikt kapeec tas straadaaja????? Ieksh MSDN izlassiiju par Set, un Get , un ja neizmanto Set.. alternatiivu itkaa nav, bet NeHe viss straadaa bez Set... . Esmu galiigi apjucis
PPS ja kaadam interesee http://nehe.gamedev.net/counter.asp?file=files/basecode/nehegl.zip |
|
Back to top |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Tue Mar 22, 2005 6:38 pm Post subject: |
|
Un kā būtu ar 248. rindiņu NeHeGL.cpp failā? |
|
Back to top |
|
|
Angel
Joined: 02 Jan 2005 Posts: 113 Location: Latvija
|
Posted: Tue Mar 22, 2005 7:07 pm Post subject: |
|
Nu jau man liekas ka es no cpp vairs nekaa nesaprotu. Tas taksh ir peec taas funkcijas Get..... Bet nu lab, apzinaos, ka no c++ saprotu maz (un ar katru miilju briidi veel mazaak... ) |
|
Back to top |
|
|
Angel
Joined: 02 Jan 2005 Posts: 113 Location: Latvija
|
Posted: Tue Mar 22, 2005 7:25 pm Post subject: |
|
Taa, ja kaadam ir laiks pasekojiet šim textam, un pasakiet vai es pareizi sapratu. ( par NeHe .cpp failu)
Veidojot paplašināto logu/latviski taa buutu pareizi?/ (CreateWindowEx) ailē " LPVOID lpParam " ieraksta to, ko veelaak caur CREATESTRUCT LPVOID lpCreateParams; var ieguut. Un tādējādi nehe pie WM_CREATE var pierakstīt Set...... . un tagad jautājums: "Vai Set.....() nevar rakstiit uzreiz aiz CreateWindowEx()? " un iztikt bez WM_CREATE Loga procedūrā. |
|
Back to top |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|