Menu

TOOLTIPS on DEVC++

2008-01-22
2012-09-26
  • keyvan eslami

    keyvan eslami - 2008-01-22

    Hi guys,

    I'm a bit new in development, so if my questions sound lame, please forgive me! ;)

    I have this problem with using TBS_TOOLTIPS for a trackbar in a window App. Obviously, I'm using DevC++. I included commctrl.h and commdlg.h in the main.c.
    I also linked to comctl32.lib in parameters option of my project. I also added the path of comctl32.lib in the list of lib directories. comctl32.dll is in system32 folder and I added its address in my compiler's options.

    Still when I compile the code, I get the " TBS_TOOLTIPS undeclared " error. I commented out #if (_WIN32_IE >= 0x0300 ) and its corresponding #endif in commctrl.h. It works but after closing the window there is this error about referenced memory.

    My questions are:
    1- What does _WIN32_IE have to do with all this? ( IE is internet explorer right? )
    2- How does system check IE version?
    3- How can I find out what version of comctl32.dll I am using?
    4- How can I fix my problem?

    I would appreciate if someone could help me out with these questions.

    Cheers

     
    • keyvan eslami

      keyvan eslami - 2008-01-23

      Awesome, Thanks a lot BiT! That worked out well.

       
    • keyvan eslami

      keyvan eslami - 2008-01-23

      Ok, So after being harassed by Dr.Wayne (kidd'n! ;) ) I refine my post to this format:

      DevC++ Format: 4.9.9.2

      OS: Windows XP Pro SysPack2

      Programming Language: C

      Sample program:

      / initializing window structure /
      ...
      / registring window /
      ...

      HWND sliderHwnd = CreateWindowEx( 
          WS_EX_CLIENTEDGE,                             
          TRACKBAR_CLASS,                // class name 
          "Front Controller",            // title (caption) 
          WS_CHILD | WS_VISIBLE | TBS_TOOLTIPS,  // style 
          0, 0,             // position 
          255, 30,                       // size 
          ParentHwnd,                       // parent window 
          NULL,                  // control identifier 
          (HINSTANCE)GetWindowLong(ParentHwnd, GWL_HINSTANCE),                       // instance 
          NULL                           // no WM_CREATE parameter 
          );
      

      / setting Max, Min, Range, TicFreq, etc /

      Compiler log:
      Compiler: Default compiler
      Building Makefile: "C:\Documents and Settings\keslami\My Documents\Haptic Belt\Makefile.win"
      Executing make clean
      rm -f main.o Haptic_Belt_private.res "Haptic Belt.exe"

      gcc.exe -c main.c -o main.o -I"C:/Dev-Cpp/include" -I"C:/Program Files/Microsoft Platform SDK/Include" -I"C:/Program Files/Microsoft Visual Studio/VC98/Include" -I"C:/Documents and Settings/keslami/My Documents/Haptic Belt" -I"C:/Documents and Settings/keslami/My Documents/Downloads/libusb-win32-device-bin-0.1.12.1/libusb-win32-device-bin-0.1.12.1/include" -I"C:/Dev-Cpp/include"

      main.c: In function CreatTool': main.c:307: error:TBS_TOOLTIPS' undeclared (first use in this function)
      main.c:307: error: (Each undeclared identifier is reported only once
      main.c:307: error: for each function it appears in.)
      main.c:332: error: `TBTS_RIGHT' undeclared (first use in this function)

      make.exe: *** [main.o] Error 1

      Execution terminated

      My Questions:

      1- What does _WIN32_IE have to do with all this? ( IE is internet explorer right? )
      2- How does system check IE version?
      3- How can I find out what version of comctl32.dll I am using?
      4- How can I fix my problem?

      Thanks everyone

       
    • BiT

      BiT - 2008-01-23

      Search feature worked for me.
      your library file should end with .a not .lib

      Having spaces in the path is just asking for problems as well, lots of info on this in the boards here just have to search.

      Start here and you should be able to get this resolved easily.
      http://sourceforge.net/forum/message.php?msg_id=2486139

      Version Information
      http://msdn2.microsoft.com/en-us/library/bb776779(VS.85).aspx

       
    • BiT

      BiT - 2008-01-23

      Working Example. Used the template for windows application

      /* CUT */

      // in your project options add -lcomctl32

      define _WIN32_IE 0x0600 //<-what you where probably missing

      include <windows.h>

      include <commctrl.h>

      / Declare Windows procedure /
      LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

      / Make the class name into a global variable /
      char szClassName[ ] = "WindowsApp";

      int WINAPI WinMain (HINSTANCE hThisInstance,
      HINSTANCE hPrevInstance,
      LPSTR lpszArgument,
      int nFunsterStil)

      {
      HWND hwnd; / This is the handle for our window /
      MSG messages; / Here messages to the application are saved /
      WNDCLASSEX wincl; / Data structure for the windowclass /

      /* The Window structure */
      wincl.hInstance = hThisInstance;
      wincl.lpszClassName = szClassName;
      wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
      wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
      wincl.cbSize = sizeof (WNDCLASSEX);
      
      /* Use default icon and mouse-pointer */
      wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
      wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
      wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
      wincl.lpszMenuName = NULL;                 /* No menu */
      wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
      wincl.cbWndExtra = 0;                      /* structure or the window instance */
      /* Use Windows's default color as the background of the window */
      wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
      
      /* Register the window class, and if it fails quit the program */
      if (!RegisterClassEx (&amp;wincl))
          return 0;
      
      /* The class is registered, let's create the program*/
      hwnd = CreateWindowEx (
             0,                   /* Extended possibilites for variation */
             szClassName,         /* Classname */
             &quot;Windows App&quot;,       /* Title Text */
             WS_OVERLAPPEDWINDOW, /* default window */
             CW_USEDEFAULT,       /* Windows decides the position */
             CW_USEDEFAULT,       /* where the window ends up on the screen */
             544,                 /* The programs width */
             375,                 /* and height in pixels */
             HWND_DESKTOP,        /* The window is a child-window to desktop */
             NULL,                /* No menu */
             hThisInstance,       /* Program Instance handler */
             NULL                 /* No Window Creation data */
             );
      
      /* Make the window visible on the screen */
      ShowWindow (hwnd, nFunsterStil);
      

      /******
      **** Added **
      ******/

              INITCOMMONCONTROLSEX icex; 
          memset(&amp;icex, 0x0, sizeof(INITCOMMONCONTROLSEX)); 
          icex.dwSize = sizeof(INITCOMMONCONTROLSEX); 
          icex.dwICC =  
          ICC_COOL_CLASSES | // Load the coolbar class.  
          ICC_BAR_CLASSES | // Load toolbar, status bar, track bar, and  
          // tooltips control classes.  
          // ICC_TREEVIEW_CLASSES | // Load tree view and tooltips control classes.  
          // ICC_DATE_CLASSES | // Load date and time picker control class.  
          // ICC_HOTKEY_CLASS | // Load hot-key control class.  
          // ICC_LISTVIEW_CLASSES | // Load list view and header control classes.  
          // ICC_PROGRESS_CLASS | // Load progress bar control class.  
          // ICC_TAB_CLASSES | // Load tab and tooltips control classes.  
          // ICC_ANIMATE_CLASS | // Load animate control class.  
          // ICC_UPDOWN_CLASS | // Load up-down control class.  
          // ICC_USEREX_CLASSES | // Load ComboBoxEx class.  
          // ICC_WIN95_CLASSES | // Load the animate control, header, hot-key,  
          // list view, progress bar, status bar, tab,  
          // tooltips, toolbar, track bar, tree view,  
          // and up-down control classes.  
          0; // allows commenting out styles 
          if(!(InitCommonControlsEx(&amp;icex))) 
          { 
          MessageBox((HWND)NULL, &quot;InitCommonControlsEx failed&quot;, &quot;Error&quot;, MB_OK); 
          return FALSE; 
          }
      

      /******
      *END OF ADD ****
      *******/

      /* Run the message loop. It will run until GetMessage() returns 0 */
      while (GetMessage (&amp;messages, NULL, 0, 0))
      {
          /* Translate virtual-key messages into character messages */
          TranslateMessage(&amp;messages);
          /* Send message to WindowProcedure */
          DispatchMessage(&amp;messages);
      }
      
      /* The program return-value is 0 - The value that PostQuitMessage() gave */
      return messages.wParam;
      

      }

      / This function is called by the Windows function DispatchMessage() /

      LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
      {
      switch (message) / handle the messages /
      {

      /******
      **** Added **
      *******/
      case WM_CREATE:
      {
      HWND sliderHwnd = CreateWindowEx( WS_EX_CLIENTEDGE, TRACKBAR_CLASS, "Front Controller",
      WS_CHILD | WS_VISIBLE | TBS_TOOLTIPS, 0, 0, 255, 30, hwnd,
      NULL, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL); // no WM_CREATE parameter
      }
      break;
      /
      *****
      ****END OF ADD ****
      *****
      /
      case WM_DESTROY:
      PostQuitMessage (0); /
      send a WM_QUIT to the message queue /
      break;
      default: /
      for messages that we don't deal with */
      return DefWindowProc (hwnd, message, wParam, lParam);
      }

      return 0;
      

      }

      / end cut /

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.