nid help in using dialog box

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

Join Date: Sep 2004
Posts: 2
Reputation: iorisendoh is an unknown quantity at this point 
Solved Threads: 0
iorisendoh iorisendoh is offline Offline
Newbie Poster

nid help in using dialog box

 
0
  #1
Mar 15th, 2005
i have a sample program,can someone help to find the error of this program or someone to correct this program coz i don't know what is the error of this program

this is the sample program of mine

  1. #include<windows.h>
  2. #include<string.h>
  3. #include<strstrea.h>
  4. #include"mydialog.h"
  5. void main()
  6. {
  7. LONG FAR PASCAL _export WindowFunc(HWND hwnd, unsigned message,
  8. WORD wParam, LONG lParam);
  9. BOOL FAR PASCAL _export DialogFunc(HWND hdwnd, unsigned message,
  10. WORD wParam, LONG lParam);
  11. char szWinName[] = "MyWin";
  12.  
  13. HANDLE hInst;
  14.  
  15. int PASCAL WinMain(HANDLE hThisInst, HANDLE hPrevInst,
  16. LPSTR lpszArgs, int nWinMode);
  17.  
  18.  
  19. }
  20. {
  21. HWND hwnd;
  22. MSG msg;
  23. WNDCLASS wcl;
  24. HANDLE hAccel;
  25.  
  26. if(!hPrevInst){
  27.  
  28. wcl.hInstance = hThisInst;
  29. wcl.lpszClassName = szWinName;
  30. wcl.lpfnWndProc =WindowFunc;
  31. wcl.style = NULL;
  32.  
  33. wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  34. wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
  35. wcl.lpszMenuName = "MYMENU";
  36.  
  37. wcl.cbClsExtra = 0;
  38. wcl.cbWndExtra = 0;
  39.  
  40. wcl.hbrBackground = GetStockObject(LTGRAY_BRUSH);
  41.  
  42. if(!RegisterClass (&wcl)) return 0;
  43. }
  44. hwnd=CreateWindow (
  45. szWinName,
  46. "Dialog Boxes",
  47. WS_OVERLAPPEDWINDOW,
  48. CW_USEDEFAULT,
  49. CW_USEDEFAULT,
  50. CW_USEDEFAULT,
  51. CW_USEDEFAULT,
  52. NULL,
  53. NULL,
  54. hThisInst,
  55. NULL
  56. );
  57. hAccel = LoadAccelerators(hThisInst, "MYMENU");
  58. hInst = hThisInst;
  59.  
  60. ShowWindow(hwnd, nWinMode);
  61.  
  62. while(GetMessage(&msg, NULL, 0, 0))
  63. {
  64. if(!TranslateAccelerator(hwnd, hAccel, &msg)) {
  65. TranslateMessage(&msg);
  66. DispatchMessage(&msg);
  67. }
  68. {
  69. return msg.wParam;
  70.  
  71.  
  72. long FAR PASCAL WindowFunc(HWND hwnd, WORD message, WORD wParam,
  73. LONG lParam)
  74. {
  75. FARPROC lpDlg;
  76.  
  77. int response;
  78.  
  79. switch(message) {
  80. case WM_COMMAND:
  81. switch(wParam) {
  82. case IDM_DIALOG1:
  83. lpDlg = MakeProcInstance ((FARPROC) DialogFunc, hInst);
  84. DialogBox(hInst,"MYDB", hwnd, lpDlg;
  85. FreeProcInstance(lpDlg);
  86. break;
  87. case IDM_DIALOG2:
  88. MessageBox(hwnd, "Not Implemented", "", MB_OK);
  89. break;
  90. case IDM_HELP:
  91. MessageBox(hwnd, "Not Impelemented", "HELP", MB_OK);
  92. break;
  93. }
  94. break;
  95. case WM_DESTROY:
  96. PostQuitMessage(0);
  97. break;
  98. }
  99.  
  100. return DefWindowProc(hwnd, message, wParam, lParam);
  101. }
  102.  
  103. BOOL FAR PASCAL DialogFunc(HWND hdwnd, unsigned message,
  104. WORD wParam, LONG lParam)
  105. {
  106.  
  107. switch(message){
  108. case WM_COMMAND:
  109. switch(wParam) {
  110. case IDCANCEL:
  111. EndDialog(hdwnd, NULL);
  112. return 1;
  113. case IDD_RED:
  114. MessageBox(hdwnd,"You Picked Red", "RED", MB_OK);
  115. return 1;
  116. case IDD_GREEN:
  117. MessageBox(hdwnd,"You Picked Green", "GREEN", MB_OK);
  118. return 1;
  119. }
  120. }
  121. return 0;
  122. }
Last edited by alc6379; Mar 15th, 2005 at 10:23 am. Reason: added [code] tags
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: nid help in using dialog box

 
0
  #2
Mar 15th, 2005
What is the error? Right off hand I can see you are mixing two entry points. void main () & WinMain. WinMain is empty. There is an example of a sekeltal app in code snippets under cplusplus. Look at that one and it will give you a good idea how to correct yours.
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



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC