16. februar 2004 - 20:21
Der er
16 kommentarer og 1 løsning
Fejl i kode ( GUI )
#include <iostream> #include <stdlib.h> #include <windows.h> const char g_szClassname[] = "myWindowClass"; LRESULT CALLBACK Wndproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hinstance = hinstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1); wc.ipszMenuName = NULL; wc.ipszClassname = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if (!registerclassex(&wc)) { MessageBox(NULL, "Window failed please try agian", "Error", MB.IconEXCLAMATION | MB_Ok); return 0; } hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "Application caption", WS_OVERLAPPEDWINDOW, CW_USEDDEFAULT, CW_USEDDEFAULT, 240, 120, NULL, NULL, HInstance, NULL); if (hwnd = 0) { MessageBox(NULL, "Window failed please try agian", "Error", MB.IconEXCLAMATION | MB_Ok); return 0; } ShowWindow(hwnd cmdshow); UpdateWindow(hwnd); while(GetMessage(&MSG, NULL, 0, 0) > 0) { TranslateMessage(&MSG); DispatchMessage(&MSG); } return Msg.wParam; } Sad og skrev dette men får en masse fejl fuldte Tutorial på winprog.org her er fejl loggen : Kompiler: Default compiler Eksekverer g++.exe... g++.exe "C:\Dev-Cpp\WND-app\koden.cpp" -o "C:\Dev-Cpp\WND-app\koden.exe" -g3 -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" C:/Dev-Cpp/WND-app/koden.cpp: In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)': C:/Dev-Cpp/WND-app/koden.cpp:33: `WndProc' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:33: (Each undeclared identifier is reported only once for each function it appears in.) C:/Dev-Cpp/WND-app/koden.cpp:36: `struct _WNDCLASSEXA' has no member named ` hinstance' C:/Dev-Cpp/WND-app/koden.cpp:36: `hinstance' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:40: `struct _WNDCLASSEXA' has no member named ` ipszMenuName' C:/Dev-Cpp/WND-app/koden.cpp:41: `struct _WNDCLASSEXA' has no member named ` ipszClassname' C:/Dev-Cpp/WND-app/koden.cpp:41: `g_szClassName' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:44: `registerclassex' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:46: `MB' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:46: `MB_Ok' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:55: `CW_USEDDEFAULT' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:56: `HInstance' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:64: `hwnd' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:64: parse error before `)' token C:/Dev-Cpp/WND-app/koden.cpp:67: parse error before `,' token C:/Dev-Cpp/WND-app/koden.cpp:70: parse error before `)' token Eksekvering afbrudt
Annonceindlæg tema
Cloud & AI
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
16. februar 2004 - 20:38
#1
LRESULT CALLBACK Wndproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) Wndproc med lille p wc.lpfnWndProc = WndProc; WndProc med stort P
16. februar 2004 - 20:39
#2
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) hInstance med stort I wc.hinstance = hinstance; hinstance med lille i
16. februar 2004 - 20:40
#3
const char g_szClassname[] = "myWindowClass"; lille n wc.ipszClassname = g_szClassName; stort N
16. februar 2004 - 20:42
#4
MB_Ok skal være MB_OK (lille->stort)
16. februar 2004 - 20:42
#5
hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "Application caption", WS_OVERLAPPEDWINDOW, CW_USEDDEFAULT, CW_USEDDEFAULT, 240, 120, NULL, NULL, HInstance, NULL); skal være: hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "Application caption", WS_OVERLAPPEDWINDOW, CW_USEDDEFAULT, CW_USEDDEFAULT, 240, 120, NULL, NULL, hInstance, NULL); (stor H -> lille h)
16. februar 2004 - 20:43
#6
MB.IconEXCLAMATION skal være MB_ICONEXCLAMATION
16. februar 2004 - 20:44
#7
CW_USEDDEFAULT skal være CW_USEDEFAULT (enkelt D)
16. februar 2004 - 20:46
#8
Jeg tror at det er de fleste fejl - ret dem og prøv at compile igen.
17. februar 2004 - 15:16
#9
Nu tror jeg jeg har fået rettet de fleste af fejlene men f¨r stadig en lang debug kode :P Kompiler: Default compiler Eksekverer g++.exe... g++.exe "C:\Dev-Cpp\WND-app\koden.cpp" -o "C:\Dev-Cpp\WND-app\koden.exe" -g3 -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" C:/Dev-Cpp/WND-app/koden.cpp: In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)': C:/Dev-Cpp/WND-app/koden.cpp:33: `WndProc' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:33: (Each undeclared identifier is reported only once for each function it appears in.) C:/Dev-Cpp/WND-app/koden.cpp:36: `struct _WNDCLASSEXA' has no member named ` hinstance' C:/Dev-Cpp/WND-app/koden.cpp:40: `struct _WNDCLASSEXA' has no member named ` ipszMenuName' C:/Dev-Cpp/WND-app/koden.cpp:41: `struct _WNDCLASSEXA' has no member named ` ipszClassname' C:/Dev-Cpp/WND-app/koden.cpp:44: `registerclassex' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:46: `MB' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:55: `CW_USEDDEFAULT' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:64: `hwnd' undeclared (first use this function) C:/Dev-Cpp/WND-app/koden.cpp:64: parse error before `)' token C:/Dev-Cpp/WND-app/koden.cpp:67: parse error before `,' token C:/Dev-Cpp/WND-app/koden.cpp:70: parse error before `)' token Eksekvering afbrudt
17. februar 2004 - 15:18
#10
Fejl i linje 33 : wc.lpfnWndProc = WndProc;
17. februar 2004 - 15:19
#11
Du mangler statdig en MB. me dpunktum og en USEDDEFAULT med 2 gange D !
17. februar 2004 - 15:20
#12
g_szClassName har også stadig stort N
17. februar 2004 - 15:22
#13
#include <iostream> #include <stdlib.h> #include <windows.h> const char g_szClassName[] = "myWindowClass"; LRESULT CALLBACK Wndproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hinstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1); wc.ipszMenuName = NULL; wc.ipszClassname = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if (!registerclassex(&wc)) { MessageBox(NULL, "Window failed please try agian", "Error", MB.IconEXCLAMATION | MB_OK); return 0; } hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "Application caption", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, hInstance, NULL); if (hwnd = 0) { MessageBox(NULL, "Window failed please try agian", "Error", MB.IconEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd cmdshow); UpdateWindow(hwnd); while(GetMessage(&MSG, NULL, 0, 0) > 0) { TranslateMessage(&MSG); DispatchMessage(&MSG); } return Msg.wParam; } Her er koden jeg bruger lige nu
17. februar 2004 - 15:24
#14
Det giver ikke fejl men: if (hwnd = 0) skal uden tvivl være: if (hwnd == 0)
17. februar 2004 - 15:25
#15
Den her linie må også være helt gal: ShowWindow(hwnd cmdshow); selvom jeg ikke lige kan gennemskue hvad det skal være.
Kurser inden for grundlæggende programmering