Message

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Message

 
0
  #1
Dec 18th, 2007
Hi to all,
I woud like to know how to destroy only a child window?I am Using Dev-C++ WIN32
Thank you for reading.What message to do i need?
Last edited by kv79; Dec 18th, 2007 at 7:12 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,494
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Message

 
0
  #2
Dec 18th, 2007
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: Message

 
0
  #3
Dec 18th, 2007
This is Test.cpp

I can compile it but not working as i wanted to work .
I want to first i see a child window and then destroy it and want to show parent.
  1.  
  2. #include <windows.h>
  3. #include <winuser.h>
  4. #include "resource.h"
  5.  
  6. /* Declare Windows procedure */
  7. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  8.  
  9. /* Make the class name into a global variable */
  10. char szClassName[ ] = "WindowsApp";
  11.  
  12. int WINAPI WinMain (HINSTANCE hThisInstance,
  13. HINSTANCE hPrevInstance,
  14. LPSTR lpszArgument,
  15. int nFunsterStil)
  16.  
  17. {
  18. HWND hwnd,lo; /* This is the handle for our window */
  19. MSG messages; /* Here messages to the application are saved */
  20. WNDCLASSEX wincl; /* Data structure for the windowclass */
  21.  
  22. /* The Window structure */
  23. wincl.hInstance = hThisInstance;
  24. wincl.lpszClassName = szClassName;
  25. wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
  26. wincl.style = CS_DBLCLKS; /* Catch double-clicks */
  27. wincl.cbSize = sizeof (WNDCLASSEX);
  28.  
  29. /* Use default icon and mouse-pointer */
  30. wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  31. wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  32. wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  33. wincl.lpszMenuName = MAKEINTRESOURCE(IDD_FILE); /* No menu */
  34. wincl.cbClsExtra = 0; /* No extra bytes after the window class */
  35. wincl.cbWndExtra = 0; /* structure or the window instance */
  36. /* Use Windows's default color as the background of the window */
  37. wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
  38.  
  39. /* Register the window class, and if it fails quit the program */
  40. if (!RegisterClassEx (&wincl))
  41. return 0;
  42.  
  43. /* The class is registered, let's create the program*/
  44. hwnd=CreateWindow( /* Extended possibilites for variation */
  45. szClassName, /* Classname */
  46. "WindowP", /* Title Text */
  47. SW_SHOW , /* default window */
  48. CW_USEDEFAULT, /* Windows decides the position */
  49. CW_USEDEFAULT, /* where the window ends up on the screen */
  50. 544, /* The programs width */
  51. 375, /* and height in pixels */
  52. 0, /* The window is a child-window to desktop */
  53. NULL, /* No menu */
  54. NULL, /* Program Instance handler */
  55. NULL /* No Window Creation data */
  56. );
  57.  
  58. lo= CreateWindowEx (
  59. WS_EX_COMPOSITED,
  60. szClassName,
  61. "WindowC",
  62. WS_BORDER,
  63. CW_USEDEFAULT,
  64. CW_USEDEFAULT,
  65. 200,
  66. 200,
  67. hwnd,
  68. NULL,
  69. NULL,
  70. NULL);
  71. /* Make the window visible on the screen */
  72. ShowWindow (lo, SW_SHOW);
  73.  
  74.  
  75. /* Run the message loop. It will run until GetMessage() returns 0 */
  76. while (GetMessage (&messages, NULL, 0, 0))
  77. {
  78. /* Translate virtual-key messages into character messages */
  79. TranslateMessage(&messages);
  80. /* Send message to WindowProcedure */
  81. DispatchMessage(&messages);
  82. }
  83.  
  84. /* The program return-value is 0 - The value that PostQuitMessage() gave */
  85. return messages.wParam;
  86. }
  87.  
  88.  
  89. /* This function is called by the Windows function DispatchMessage() */
  90.  
  91. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  92. {
  93. switch (message) /* handle the messages */
  94. {
  95.  
  96. case WM_COMMAND:
  97. {
  98.  
  99. switch (LOWORD(wParam))
  100. {
  101.  
  102. case IDD_FILE_EXIT:{
  103. PostMessage(hwnd,WM_CLOSE,0,0);
  104. ShowWindow(hwnd,SW_SHOW);
  105. }
  106. case IDD_HELP_ABOUT:
  107.  
  108.  
  109. default:;
  110. }
  111. }
  112.  
  113. case WM_DESTROY:
  114. PostQuitMessage(0); /* send a WM_QUIT to the message queue */
  115. break;
  116. default: /* for messages that we don't deal with */
  117. return DefWindowProc (hwnd, message, wParam, lParam);
  118. }
  119.  
  120. return 0;
  121. }
Last edited by kv79; Dec 18th, 2007 at 11:06 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: Message

 
0
  #4
Dec 18th, 2007
resource.h


  1. //{{NO_DEPENDENCIES}}
  2. #include <winuser.h>
  3. #include <windows.h>
  4.  
  5. #define IDD_FILE 6
  6.  
  7. #define IDD_HELP_ABOUT 3
  8.  
  9. #define IDD_FILE_EXIT 2
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: Message

 
0
  #5
Dec 18th, 2007
Test_rc.rc

  1. #define "resource.h"
  2.  
  3. #include <windows.h>
  4. #include <winuser.h>
  5.  
  6. #define IDD_FILE 6
  7. #define IDD_FILE_EXIT 2
  8. #define IDD_HELP_ABOUT 3
  9.  
  10.  
  11. IDD_FILE MENU
  12. BEGIN
  13.  
  14. POPUP "&EXIT"
  15.  
  16. BEGIN
  17. MENUITEM "&ODMAH",IDD_FILE_EXIT
  18. END
  19.  
  20. POPUP "HE&LP"
  21. BEGIN
  22. MENUITEM "Abou&t",IDD_HELP_ABOUT
  23. END
  24. END
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,494
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Message

 
0
  #6
Dec 18th, 2007
>>PostMessage(hwnd,WM_CLOSE,0,0);
You may be attempting to close the wrong window. Try making lo global and using that instead of the hwnd that is pass to WindowProcedure(). Not sure if that will fix the problem but its worth a try.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: Message

 
0
  #7
Dec 18th, 2007
this is without global lo


102 C:\Documents and Settings\USER\Desktop\Test\Test.cpp



`lo' undeclared (first use this function)





I do not know how to set global lo.
Last edited by kv79; Dec 18th, 2007 at 11:23 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,494
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Message

 
0
  #8
Dec 18th, 2007
>> do not know how to set global lo
delete lo from line 18 and declare it on line 8. Leave hwnd where it is on line 18.
Last edited by Ancient Dragon; Dec 18th, 2007 at 11:28 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: Message

 
0
  #9
Dec 18th, 2007
OK that working,but he did not show me the parent window.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,494
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Message

 
0
  #10
Dec 18th, 2007
I'm sorry but your problem is somewhat more complicated than I have time to work on this evening or tomorrow. Hope someone else can help you out now.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC