Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
#pragma comment(lib,"IPHlpApi.Lib") 
#pragma comment(lib, "ws2_32.lib")

#include "windows.h"
#include <iphlpapi.h>		//IP Helper api
#include "resource.h"

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
BOOL    CALLBACK IpDlgProc (HWND, UINT, WPARAM, LPARAM) ;

TCHAR szAppName[] = TEXT ("Fire") ;
//HWND hwnd;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     HWND     hwnd ;
     MSG      msg ;
     WNDCLASS wndclass ;
     
     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU1); ;
     wndclass.lpszClassName = szAppName ;
     
     if (!RegisterClass (&wndclass))
     {
          MessageBox (NULL, TEXT ("This program requires Windows NT!"),
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }
     
     hwnd = CreateWindow (szAppName, TEXT ("Fire"),
                          WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          NULL, NULL, hInstance, NULL) ;

     
     ShowWindow (hwnd, iCmdShow) ;
     UpdateWindow (hwnd) ;
  
     while (GetMessage (&msg, NULL, 0, 0))
     {
          TranslateMessage (&msg) ;
          DispatchMessage (&msg) ;
     }
     return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	 static HINSTANCE hInstance ;    
     HMENU      hMenu ;
     
     switch (message)
     {

	 case WM_CREATE :
          hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
          return 0 ;

     case WM_COMMAND:
          hMenu = GetMenu (hwnd) ;
          
          switch (LOWORD (wParam))
          {
                       
          case ID_FILE_EXIT:
               SendMessage (hwnd, WM_CLOSE, 0, 0) ;
               return 0 ;
               
        
		  case ID_TOOL_GETIPINFO:
			  DialogBox (hInstance, TEXT ("AboutBox"), hwnd, IpDlgProc) ;              
			  break;

          case ID_HELP_HELP:
               MessageBox (hwnd, TEXT ("Help not yet implemented!"),
                           szAppName, MB_ICONEXCLAMATION | MB_OK) ;
               return 0 ;
               
          case ID_HELP_ABOUT:
               MessageBox (hwnd, TEXT ("Project By\n\n"),
                           szAppName, MB_ICONINFORMATION | MB_OK) ;
               return 0 ;
          }
          break ;
          
         case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}

BOOL CALLBACK IpDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
     switch (message)
     {
     case WM_INITDIALOG :
          return TRUE ;
          
     case WM_COMMAND :
          switch (LOWORD (wParam))
          {
          case IDOK :
          case IDCANCEL :
               EndDialog (hDlg, 0) ;
               return TRUE ;
          }
          break ;
     }
     return FALSE ;
}
Posted
Updated 3-Mar-12 6:25am
v3
Comments
Mohibur Rashid 2-Mar-12 19:45pm    
what is the question? where is the problem? where is the trouble statement?

Looks like the call to DialogBox is screwy to me. I've not heard of a DialogTemplate called "AboutBox". Is this something you have implemented elsewhere?

I'm more used to calling this using a resource_id to pull a dialog box out of the exe's resource section.

I.e
DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUT_BOX), hwnd, lpDlgProc);

Where IDD_ABOUT_BOX is #defined somewhere and is used as the resource identifier for the dialog in the resource editor.
 
Share this answer
 
DialogBox (hInstance, TEXT ("AboutBox"), hwnd, IpDlgProc)

3rd parameter should be MAKEINTRESOURCE(IDD_DIALOG1)
where IDD_DIALOG1 is the id of dilogbox

DialogBox (hInstance, MAKEINTRESOURCE(IDD_DIALOG1), hwnd, IpDlgProc)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900