Click here to Skip to main content
15,899,025 members

Comments by R1S8K (Top 14 by date)

R1S8K 23-Dec-23 3:27am View    
I converted the code to work in C.

I have now one issue where I want to embed your code in my project. But I want to understand this line and convert it to if statement style:

HWND hWndFrom = nCmdId == GO_PAGE_1 ? hMainPage : nCmdId == GO_PAGE_2 ? hPage_1 : hPage_2;

Can you explain how this line works ? and how to convert it to if statement style ?
R1S8K 25-Nov-23 7:17am View    
What should I change if I want to run in C style ?
R1S8K 23-Nov-23 4:17am View    
OK, I ran the code in C++ and changed the wWINMAIN to this one:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int nCmdShow)


and it's working, the example runs smoothly and I got the idea. Now I need just to get the grasp on the example and embed it in my code.
R1S8K 23-Nov-23 4:11am View    
OK, I think your code is in C++
R1S8K 23-Nov-23 4:08am View    
I got these errors:


-------------- Build: Release in code_project_example (compiler: GNU GCC Compiler)---------------

gcc.exe -Wall -O2  -c "D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c" -o obj\Release\main.o
gcc.exe  -o bin\Release\code_project_example.exe obj\Release\main.o  -s  
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c: In function 'CreatePage':
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:32:3: error: 'reinterpret_cast' undeclared (first use in this function)
   reinterpret_cast<hmenu>(uWindowId), // menu handle or child identifier
   ^~~~~~~~~~~~~~~~
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:32:3: note: each undeclared identifier is reported only once for each function it appears in
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:32:20: error: expected expression before 'HMENU'
   reinterpret_cast<hmenu>(uWindowId), // menu handle or child identifier
                    ^~~~~
In file included from D:/Program_Files/CodeBlocks/MinGW/x86_64-w64-mingw32/include/winnt.h:9,
                 from D:/Program_Files/CodeBlocks/MinGW/x86_64-w64-mingw32/include/minwindef.h:163,
                 from D:/Program_Files/CodeBlocks/MinGW/x86_64-w64-mingw32/include/windef.h:8,
                 from D:/Program_Files/CodeBlocks/MinGW/x86_64-w64-mingw32/include/windows.h:69,
                 from D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:1:
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:25:9: error: too few arguments to function 'CreateWindowExA'
  hWnd = CreateWindowEx(
         ^~~~~~~~~~~~~~
In file included from D:/Program_Files/CodeBlocks/MinGW/x86_64-w64-mingw32/include/windows.h:72,
                 from D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:1:
D:/Program_Files/CodeBlocks/MinGW/x86_64-w64-mingw32/include/winuser.h:2137:26: note: declared here
   WINUSERAPI HWND WINAPI CreateWindowExA(DWORD dwExStyle,LPCSTR lpClassName,LPCSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam);
                          ^~~~~~~~~~~~~~~
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c: In function 'OnCreate':
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:50:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
  WNDCLASSEX wndClassEx{}; // class structure
                       ^
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:51:2: error: 'wndClassEx' undeclared (first use in this function); did you mean 'ReadClassStm'?
  wndClassEx.cbSize = sizeof wndClassEx;
  ^~~~~~~~~~
  ReadClassStm
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:53:27: error: 'reinterpret_cast' undeclared (first use in this function)
  wndClassEx.lpfnWndProc = reinterpret_cast<wndproc>(GetWindowLongPtr(hWnd, GWLP_WNDPROC));
                           ^~~~~~~~~~~~~~~~
D:\Programming\desktop_programming\C\windows api programming\code_project_example\code_project_example\main.c:53:44: error: expected expression before 'WNDPROC'
  wndClassEx.lpfnWndProc = reinterpret_cast<wndproc>(GetWindowLongPtr(hWnd, GWLP_WNDPROC));
                                            ^~~~~~~
...