Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   The Pager Control (http://www.programmingforums.org/showthread.php?t=14839)

pcbrainbuster Jan 1st, 2008 12:09 AM

The Pager Control
 
Sup guys :),

To start off with(my posting) I'd like to ask how to work with a pager control, so could someone please post a (Win32) piece of code showing me how to succesfully create the control. Here are the guidlines -

- There needs to be three buttons in the pager control
- And that's it :ooh:

Thanks :icon_twisted:.

Jessehk Jan 1st, 2008 12:15 AM

Re: The Pager Control
 
I don't know anything about win32, but I do know that you're going to have to be a lot more specific if you expect any useful responses.

Ancient Dragon Jan 1st, 2008 7:12 AM

Re: The Pager Control
 
I don't know what a pager control is but there is a lot of information about them. If you had bothered to use google you could have saved yourself a lot of time.

pcbrainbuster Jan 1st, 2008 12:53 PM

Re: The Pager Control
 
Well guys I did bother but you get info about pager controls that are relative to other programming/web langues... If you were to try and type down something like "C++ Win32 Pager Control" you would get unrelated results... You get a lot of MFC related example but like I said no Win32 info :( which is why I posted.

Has anyone got any idea?

Thanks for the help/posts :).

Ancient Dragon Jan 1st, 2008 3:39 PM

Re: The Pager Control
 
If you found one for MFC then it should not be difficult (probably) to port to pure win32 api functions. Afterall, MFC is just a wrapper for win32 api. Post link and I'll see what I can do to help you out.

pcbrainbuster Jan 1st, 2008 7:00 PM

Re: The Pager Control
 
Thanks for another post!!! :)

And here's one link now - http://www.codeguru.com/cpp/controls...cle.php/c2199/

Its not even close to what I would expect... If you don't mind could you please create an example with guidlines from above? Here's some of it done already -

:

  1. /*
  2. --------------NOTICE-------------
  3. As far as I know all I need to do now is to handle a message which is think was PGM_CALCSIZE or so.
  4. But I do not know how :( So I'm hoping that you can help me.
  5. */
  6.  
  7. #include <windows.h>
  8. #include <commctrl.h>
  9.  
  10. const char *ClsName = "BasicApp";
  11. const char *WndName = "Using Pagers";
  12.  
  13. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
  14. WPARAM wParam, LPARAM lParam);
  15.  
  16. HINSTANCE hInstance;
  17.  
  18. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  19. LPSTR lpCmdLine, int nCmdShow)
  20. {
  21. MSG Msg;
  22. HWND hWnd;
  23. WNDCLASSEX WndClsEx;
  24.  
  25. // Create the application window
  26. WndClsEx.cbSize = sizeof(WNDCLASSEX);
  27. WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
  28. WndClsEx.lpfnWndProc = WndProc;
  29. WndClsEx.cbClsExtra = 0;
  30. WndClsEx.cbWndExtra = 0;
  31. WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  32. WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);
  33. WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  34. WndClsEx.lpszMenuName = NULL;
  35. WndClsEx.lpszClassName = ClsName;
  36. WndClsEx.hInstance = hInstance;
  37. WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  38.  
  39. // Register the application
  40. RegisterClassEx(&WndClsEx);
  41.  
  42. // Create the window object
  43. hWnd = CreateWindow(ClsName,
  44. WndName,
  45. WS_OVERLAPPEDWINDOW,
  46. CW_USEDEFAULT,
  47. CW_USEDEFAULT,
  48. CW_USEDEFAULT,
  49. CW_USEDEFAULT,
  50. NULL,
  51. NULL,
  52. hInstance,
  53. NULL);
  54.  
  55. // Find out if the window was created
  56. if( !hWnd ) // If the window was not created,
  57. return 0; // stop the application
  58.  
  59. // Display the window to the user
  60. ShowWindow(hWnd, SW_SHOWNORMAL);
  61. UpdateWindow(hWnd);
  62.  
  63. // Decode and treat the messages
  64. // as long as the application is running
  65. while( GetMessage(&Msg, NULL, 0, 0) )
  66. {
  67. TranslateMessage(&Msg);
  68. DispatchMessage(&Msg);
  69. }
  70.  
  71. return Msg.wParam;
  72. }
  73.  
  74. LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
  75. {
  76.  
  77. static HWND Pager, Button1, Button2, Button3;
  78. static INITCOMMONCONTROLSEX ICC;
  79. static LPNMPGCALCSIZE pCalcSize;
  80.  
  81. switch (Msg)
  82. {
  83.  
  84.   case WM_DESTROY :
  85.  
  86.   PostQuitMessage(WM_QUIT);
  87.  
  88.   break;
  89.  
  90.   case WM_CLOSE :
  91.  
  92.   DestroyWindow(hWnd);
  93.  
  94.   break;
  95.  
  96.   case WM_CREATE :
  97.  
  98.   InitCommonControlsEx(&ICC);
  99.  
  100.   ICC.dwSize = sizeof(ICC);
  101.   ICC.dwICC = ICC_PAGESCROLLER_CLASS;
  102.  
  103.   Pager = CreateWindow(WC_PAGESCROLLER, NULL, WS_VISIBLE | WS_CHILD | WS_BORDER | PGS_HORZ, 0, 0, 100, 20, hWnd, (HMENU)101, hInstance, NULL);
  104.   Button1 = CreateWindow("BUTTON", "Button 1", WS_VISIBLE | WS_CHILD | WS_BORDER | BS_PUSHBUTTON, 0, 0, 0, 0, Pager, (HMENU)102, hInstance, NULL);
  105.   Button2 = CreateWindow("BUTTON", "Button 2", WS_VISIBLE | WS_CHILD | WS_BORDER | BS_PUSHBUTTON, 0, 0, 0, 0, Pager, (HMENU)103, hInstance, NULL);
  106.   Button3 = CreateWindow("BUTTON", "Button 3", WS_VISIBLE | WS_CHILD | WS_BORDER | BS_PUSHBUTTON, 0, 0, 0, 0, Pager, (HMENU)104, hInstance, NULL);
  107.  
  108.   SendMessage(Pager, PGM_SETCHILD, 0, (LPARAM)Button1);
  109.   SendMessage(Pager, PGM_SETCHILD, 0, (LPARAM)Button2);
  110.   SendMessage(Pager, PGM_SETCHILD, 0, (LPARAM)Button3);
  111.  
  112.   break;
  113.  
  114. }
  115.  
  116. return DefWindowProc(hWnd, Msg, wParam, lParam);
  117.  
  118. }


Thanks! :)

pcbrainbuster Jan 3rd, 2008 7:57 AM

Re: The Pager Control
 
After a little bit more of work I figured out how to size it properly but now the problem is that the pager control acts up wierdly -

:

  1. #include <windows.h>
  2. #include <commctrl.h>
  3.  
  4. const char *ClsName = "BasicApp";
  5. const char *WndName = "Using Pagers";
  6.  
  7. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
  8. WPARAM wParam, LPARAM lParam);
  9.  
  10. HINSTANCE hInstance;
  11.  
  12. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  13. LPSTR lpCmdLine, int nCmdShow)
  14. {
  15. MSG Msg;
  16. HWND hWnd;
  17. WNDCLASSEX WndClsEx;
  18.  
  19. // Create the application window
  20. WndClsEx.cbSize = sizeof(WNDCLASSEX);
  21. WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
  22. WndClsEx.lpfnWndProc = WndProc;
  23. WndClsEx.cbClsExtra = 0;
  24. WndClsEx.cbWndExtra = 0;
  25. WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  26. WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);
  27. WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  28. WndClsEx.lpszMenuName = NULL;
  29. WndClsEx.lpszClassName = ClsName;
  30. WndClsEx.hInstance = hInstance;
  31. WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  32.  
  33. // Register the application
  34. RegisterClassEx(&WndClsEx);
  35.  
  36. // Create the window object
  37. hWnd = CreateWindow(ClsName,
  38. WndName,
  39. WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU,
  40. CW_USEDEFAULT,
  41. CW_USEDEFAULT,
  42. 216,
  43. 72,
  44. NULL,
  45. NULL,
  46. hInstance,
  47. NULL);
  48.  
  49. // Find out if the window was created
  50. if( !hWnd ) // If the window was not created,
  51. return 0; // stop the application
  52.  
  53. // Display the window to the user
  54. ShowWindow(hWnd, SW_SHOWNORMAL);
  55. UpdateWindow(hWnd);
  56.  
  57. // Decode and treat the messages
  58. // as long as the application is running
  59. while( GetMessage(&Msg, NULL, 0, 0) )
  60. {
  61. TranslateMessage(&Msg);
  62. DispatchMessage(&Msg);
  63. }
  64.  
  65. return Msg.wParam;
  66. }
  67.  
  68. LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
  69. {
  70.  
  71. static HWND Pager, Button1, Button2, Button3;
  72. static INITCOMMONCONTROLSEX ICC;
  73.  
  74. switch (Msg)
  75. {
  76.  
  77.   case WM_DESTROY :
  78.  
  79.   PostQuitMessage(WM_QUIT);
  80.  
  81.   break;
  82.  
  83.   case WM_CLOSE :
  84.  
  85.   DestroyWindow(hWnd);
  86.  
  87.   break;
  88.  
  89.   case WM_NOTIFY :
  90.  
  91.   switch(((LPNMHDR)lParam)->code)
  92.   {
  93.  
  94.     case PGN_CALCSIZE :
  95.     {
  96.  
  97.     LPNMPGCALCSIZE pCalcSize = (LPNMPGCALCSIZE)lParam;
  98.  
  99.     switch(pCalcSize->dwFlag)
  100.     {
  101.  
  102.       case PGF_CALCWIDTH :
  103.  
  104.       pCalcSize->iWidth = 200;
  105.       pCalcSize->iHeight = 0;
  106.  
  107.       break;
  108.  
  109.     }
  110.  
  111.     }
  112.  
  113.     break;
  114.  
  115.   }
  116.  
  117.   break;
  118.  
  119.   case WM_COMMAND :
  120.  
  121.   if(HIWORD(wParam) == BN_CLICKED)
  122.   {
  123.  
  124.     switch(LOWORD(wParam))
  125.     {
  126.  
  127.     case 101 :
  128.  
  129.       MessageBox(hWnd, "Button 1 clicked...", "Status", MB_OK);
  130.  
  131.     break;
  132.  
  133.     case 102 :
  134.  
  135.       MessageBox(hWnd, "Button 2 clicked...", "Status", MB_OK);
  136.  
  137.     break;
  138.  
  139.     case 103 :
  140.  
  141.       MessageBox(hWnd, "Button 3 clicked...", "Status", MB_OK);
  142.  
  143.     break;
  144.  
  145.     }
  146.  
  147.   }
  148.  
  149.   break;
  150.  
  151.   case WM_CREATE :
  152.  
  153.   InitCommonControlsEx(&ICC);
  154.  
  155.   ICC.dwSize = sizeof(ICC);
  156.   ICC.dwICC = ICC_PAGESCROLLER_CLASS;
  157.  
  158.   Pager = CreateWindow(WC_PAGESCROLLER, NULL, WS_VISIBLE | WS_CHILD | WS_BORDER | PGS_HORZ, 5, 5, 200, 30, hWnd, NULL, hInstance, NULL);
  159.   Button1 = CreateWindow("BUTTON", "Button 1", WS_VISIBLE | WS_CHILD | WS_BORDER | BS_PUSHBUTTON, 0, 0, 100, 20, Pager, (HMENU)101, hInstance, NULL);
  160.   Button2 = CreateWindow("BUTTON", "Button 2", WS_VISIBLE | WS_CHILD | WS_BORDER | BS_PUSHBUTTON, 100, 0, 100, 20, Pager, (HMENU)102, hInstance, NULL);
  161.   Button3 = CreateWindow("BUTTON", "Button 3", WS_VISIBLE | WS_CHILD | WS_BORDER | BS_PUSHBUTTON, 200, 0, 100, 20, Pager, (HMENU)103, hInstance, NULL);
  162.  
  163.   SendMessage(Pager, PGM_SETCHILD, 0, (LPARAM)Button1);
  164.   SendMessage(Pager, PGM_SETCHILD, 0, (LPARAM)Button2);
  165.   SendMessage(Pager, PGM_SETCHILD, 0, (LPARAM)Button3);
  166.  
  167.   break;
  168.  
  169. }
  170.  
  171. return DefWindowProc(hWnd, Msg, wParam, lParam);
  172.  
  173. }

Any ideas?

Thanks.

Ancient Dragon Jan 3rd, 2008 4:38 PM

Re: The Pager Control
 
I think you are misusing the pager control. From what I see and understand the pager control is a container for another object that is too big to see all at one time. You can only put one other control on the pager control as explained here. You are attempting to put three buttons on it. What you may want to do is create a toolbar control, but all the buttons on that then add the toolbar to the pager control.

pcbrainbuster Jan 3rd, 2008 7:22 PM

Re: The Pager Control
 
Thanks for your reply but man I hate toolbas because they are hard to use! Oh well, no pain no gain I guess :)

Thank you!

pcbrainbuster Jan 3rd, 2008 7:47 PM

Re: The Pager Control
 
Man I already got some trouble! I can't seem to find out how to assign a button to the toolbar, I keep searching but come up with resources which show how to assign images which is not what I need. :)

Please help! :|

Thanks !!!


All times are GMT -5. The time now is 3:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC