Chat on IRC |
help with windows programming
Posted by mc0282 [send private reply] at August 03, 2002, 05:42:59 PM
hello i need little hand with this code . this my code and i having a little hard time with it .
THE HEADER FILE CODES #include <windows.h> // Get Text from edit/hWnd void GetText(HWND hWnd, char* cBuf, int nBufLen) { SendMessage(hWnd, WM_GETTEXT, (long) nBufLen, (LPARAM)(LPCSTR) cBuf); } >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> THE CODES #include<windows.h> #include"bitch.h" LRESULT CALLBACK WndProc(HWND hWnd,UINT iMsg,WPARAM wParam,LPARAM lParam) { switch(iMsg) { case WM_CLOSE: PostQuitMessage(0); break; case WM_DESTROY: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd,iMsg,wParam,lParam); } return 0 ; } int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) { const char* AppName = "Melvyn"; WNDCLASSEX wc; HWND hwnd; HWND hE3; MSG msg; char name; wc.cbSize = sizeof(wc); wc.style = CS_HREDRAW | CS_VREDRAW; 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)GetStockObject(GRAY_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = AppName; wc.hIconSm = LoadIcon(NULL,IDI_APPLICATION); RegisterClassEx(&wc); hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,AppName,"Melvyn",WS_OVERLAPPED,0,0,300,300,NULL,NULL,hInstance,NULL); hE3 = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", NULL, WS_CHILD | ES_MULTILINE, 5, 100, 100, 20, hwnd, NULL, hInstance, NULL); ShowWindow(hwnd,nShowCmd); ShowWindow(hE3,nShowCmd); UpdateWindow(hwnd); if(hE3 =="melvyn" ) { MessageBox(hwnd,"hello","cool",MB_OK); // just a example } while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam ; } AND I GET ERROR EVERYTHING TIME I TRY TO COMPILE IT I CAN'T UNDERSTAND ERROR IS LITTLE CONFUSING BUT EVERYONE MAKE MISTAKE error C2446: '==' : no conversion from 'char *' to 'struct HWND__ *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast C:\Windows\Desktop\Visual C++\Mel\Mel.cpp(61) : error C2230: '==' : indirection to different types Error executing cl.exe. Mel.exe - 2 error(s), 0 warning(s) IF YOU COULD FIX UP FOR ME OR EXPLAIN WHAT IM DOING WRONG LET ME KNOW THANK YOU
Posted by taubz [send private reply] at August 03, 2002, 07:39:19 PM
It would have been helpful if you told us what line was line 61, but I guess it's the one with " if(hE3 =="melvyn" ) ".
Here's a translation of the error message, which should help you to translate similar errors in the future: "error C2446: '==' : no conversion from 'char *' to 'struct HWND__ *'" The compiler doesn't know how to compare a variable of type "char *" to a variable of type "struct HWND__*" and the errors occurs somewhere around an "==" operator. From the line number, we can see that hE3 is defined as a HWND and "melvyn" is of course a char *. HWNDs aren't strings, they're handles of some sort. So, your attempt to compare the char* and the handle cannot be done. - tauz
Register as a new user | ||||