c++ - Windowing Functions with cpp in Windows -


i have been learning opengl cpp using www.cplusplus.com . have been using code blocks , program goes this

/*  trim fat windows*/ #define win32_lean_and_mean #pragma comment(linker, "/subsystem:windows") /*  pre-processor directives*/ #include "stdafx.h" #include <windows.h> #include <iostream> /*  windows procedure event handler*/ lresult callback wndproc(hwnd hwnd, uint message, wparam wparam, lparam lparam) {    paintstruct paintstruct;     /*  device context*/     hdc hdc;     /*  text display*/     char string[] = "hello, world!";     /*  switch message, condition met execute*/     switch(message)     {         /*  window being created*/         case wm_create:             return 0;             break;         /*  window closing*/         case wm_close:             postquitmessage(0);             return 0;             break;         /*  window needs update*/         case wm_paint:             hdc = beginpaint(hwnd,&paintstruct);             /*  set txt color blue*/             settextcolor(hdc, colorref(0x00ff0000));             /*  display text in middle of window*/             textout(hdc,150,150,string,sizeof(string)-1);             endpaint(hwnd, &paintstruct);             return 0;             break;         default:             break;     }     return (defwindowproc(hwnd,message,wparam,lparam)); } /*  main function*/ int apientry winmain(hinstance hinstance,                      hinstance hprevinstance,                      lpstr     lpcmdline,                      int       ncmdshow) {     wndclassex  windowclass;        //window class     hwnd        hwnd;               //window handle     msg         msg;                //message     bool        done;               //flag saying when app complete     /*  fill out window class structure*/     windowclass.cbsize = sizeof(wndclassex);     windowclass.style = cs_hredraw | cs_vredraw;     windowclass.lpfnwndproc = wndproc;     windowclass.cbclsextra = 0;     windowclass.cbwndextra = 0;     windowclass.hinstance = hinstance;     windowclass.hicon = loadicon(null, idi_application);     windowclass.hcursor = loadcursor(null, idc_arrow);     windowclass.hbrbackground = (hbrush)getstockobject(white_brush);     windowclass.lpszmenuname = null;     windowclass.lpszclassname = "myclass";     windowclass.hiconsm = loadicon(null, idi_winlogo);     /*  register window class*/     if (!registerclassex(&windowclass))     {         return 0;     }     /*  class registerd, create window*/     hwnd = createwindowex(null,     //extended style         "myclass",          //class name         "a real win app",       //app name         ws_overlappedwindow |       //window style         ws_visible |         ws_sysmenu,         100,100,            //x/y coords         400,400,            //width,height         null,               //handle parent         null,               //handle menu         hinstance,          //application instance         null);              //no parameter's     /*  check if window creation failed*/     if (!hwnd)         return 0;     done = false; //initialize loop condition variable     /*  main message loop*/     while(!done)     {         peekmessage(&msg,null,null,null,pm_remove);         if (msg.message == wm_quit) //check quit message         {             done = true; //if found, quit app         }         else         {             /*  translate , dispatch event queue*/             translatemessage(&msg);             dispatchmessage(&msg);         }     }     return msg.wparam; } 

i have compiled , getting linker errors settextcolor, textout , getstockobject "undefined reference to". have been including required files again , again landing same trouble.

i have been including "stdafx.h" , without success. landing same trouble again. way of getting round error?

i can't make comment here reason, i'll put in answer:

du mean compiler error ("not defined")? because if linker error ("undefined reference to..."), means have not included corresponding library (gdi32 believe).


Comments