Well, im a beginner programmer, trying to make my own proggy in Dev C++ but i have massive problem with dialog, this doesnt work (using mdi example):

mdi_unit.h

#define CM_WINDOW_TILEVERT	9084
#define CM_WINDOW_TILEHORZ	9083
#define CM_WINDOW_ARRANGE	9082
#define CM_WINDOW_TILE	9081
#define CM_WINDOW_CASCADE	9080
#define CM_EDIT_PASTE	9079
#define CM_EDIT_COPY	9078
#define CM_EDIT_CUT	9077
#define CM_EDIT_UNDO	9076
#define CM_EDIT_REDO    9075
#define CM_FILE_SAVEAS	9074
#define CM_FILE_SAVE	9073
#define CM_FILE_OPEN	9072
#define CM_FILE_EXIT	9071
#define CM_FILE_NEW	    9070
#define CM_HELP_ABOUT   9069
#define CM_HELP_TIPS    9068
#define IDM_HELPCONTENTS    9067
#define IDM_HELPSEARCH  9066
#define IDM_HELPHELP    9065
#define CM_SHOW_MAINBAR 9064
#define CM_HIDE_MAINBAR 9063
#define CM_FORMAT_WORDWRAP 9062
#define CM_LAUNCH_CALCULATOR 9061
#define CM_LAUNCH_PAINT 9060
#define CM_LAUNCH_CP 9059
#define CM_LAUNCH_SR 9058
#define CM_LAUNCH_VC 9057
#define CM_LAUNCH_WE 9056
#define CM_LICENSE 9055
#define CM_SHOW_STATUSBAR 9054
#define CM_HIDE_STATUSBAR 9053
#define CM_SHOW_EDITAREA 9052
#define CM_HIDE_EDITAREA 9051
#define CM_SHOW_ALL 9050
#define CM_HIDE_ALL 9049
#define CM_MOVE_STATUSBAR 9048
#define CM_RESTORE_STATUSBAR 9047
#define CM_MOVE_EDITAREA 9046
#define CM_RESTORE_EDITAREA 9045
#define CM_RESTORE_ALL 9044
#define CM_MOVE_ALL 9043
#define CM_RECYCLER 9042
#define CM_LAUNCH_RE 9041
#define CM_LAUNCH_CHARMAP 9040
#define CM_LAUNCH_TM 9039
#define CM_DIALOGXD 9038

mdi_unit.c

#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include <conio.h>

#include "mdi_unit.h"

#define ID_STATUSBAR       4997
#define ID_TOOLBAR         4998

#define ID_MDI_CLIENT      4999
#define ID_MDI_FIRSTCHILD  50000

#define IDC_CHILD_EDIT      2000

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT Message, WPARAM wParam,
   LPARAM lParam);

char g_szAppName[] = "MyMDIWindow";
char g_szChild[] = "MyMDIChild";
HINSTANCE g_hInst;
HWND g_hMDIClient, g_hStatusBar, g_hToolBar, DialogBox;
HWND g_hMainWindow;

BOOL LoadFile(HWND hEdit, LPSTR pszFileName)
{
   HANDLE hFile;
   BOOL bSuccess = FALSE;

   hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
      OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
   if(hFile != INVALID_HANDLE_VALUE)
   {
      DWORD dwFileSize;
      dwFileSize = GetFileSize(hFile, NULL);
      if(dwFileSize != 0xFFFFFFFF)
      {
         LPSTR pszFileText;
         pszFileText = LPSTR(GlobalAlloc(GPTR, dwFileSize + 1));
         if(pszFileText != NULL)
         {
            DWORD dwRead;
            if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL))
            {
               pszFileText[dwFileSize] = 0;
               if(SetWindowText(hEdit, pszFileText))
                  bSuccess = TRUE;
            }
            GlobalFree(pszFileText);
         }
      }
      CloseHandle(hFile);
   }
   return bSuccess;
}

BOOL SaveFile(HWND hEdit, LPSTR pszFileName)
{
   HANDLE hFile;
   BOOL bSuccess = FALSE;

   hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL,
      CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
   if(hFile != INVALID_HANDLE_VALUE)
   {
      DWORD dwTextLength;
      dwTextLength = GetWindowTextLength(hEdit);
      if(dwTextLength > 0)
      {
         LPSTR pszText;
         pszText = LPSTR(GlobalAlloc(GPTR, dwTextLength + 1));
         if(pszText != NULL)
         {
            if(GetWindowText(hEdit, pszText, dwTextLength + 1))
            {
               DWORD dwWritten;
               if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL))
                  bSuccess = TRUE;
            }
            GlobalFree(pszText);
         }
      }
      CloseHandle(hFile);
   }
   return bSuccess;
}

BOOL GetFileName(HWND hwnd, LPSTR pszFileName, BOOL bSave)
{
   OPENFILENAME ofn;

   ZeroMemory(&ofn, sizeof(ofn));
   pszFileName[0] = 0;

   ofn.lStructSize = sizeof(ofn);
   ofn.hwndOwner = hwnd;
   ofn.lpstrFilter = "All Supported Files (*.*)\0*.txp; *.nfo; *.wri; *.cfg; *.win; *.layout; *.cnt; *.frm; *.me; *.!!!; *.wtf; *.txt; *.lua; *.diz; *.dat; *.log;\0Proggy Text Files (*.txp)\0*.txp\0Info File Database Files (*.nfo)\0*.nfo\0Windows Write Files (*.wri)\0*.wri\0Makefile Files (*.win)\0*.win\0LAYOUT Files (*.layout)\0*.layout\0Confriguation Files (*.cfg)\0*.cfg\0Help Contents Files (*.cnt)\0*.cnt\0Form Files (*.frm)\0*.frm\0ASCII Text Document Files (*.me)\0*.me\0!!! Text Files (*.!!!)\0*.!!!\0Warcraft Text Files (*.wtf)\0*.wtf\0Text Files (*.txt)\0*.txt\0LUA Files (*.lua)\0*.lua\0Description Files (*.diz)\0*.diz\0Data Files (*.dat)\0*.dat\0Log Files (*.log)\0*.log\0------------------------------------------------\0*.txp\0Try to get text from any file (May result in crash!)\0*.*\0------------------------------------------------\0*.txp\0All Files (*.*)\0*.*\0\0";
   ofn.lpstrFile = pszFileName;
   ofn.nMaxFile = MAX_PATH;
   ofn.lpstrDefExt = "txt";

   if(bSave)
   {
      ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
         OFN_OVERWRITEPROMPT | OFN_SHOWHELP;
      if(!GetSaveFileName(&ofn))
         return FALSE;
   }
   else
   {
      ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_SHOWHELP;
      if(!GetOpenFileName(&ofn))
         return FALSE;
   }
   return TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
   LPSTR lpszCmdParam, int nCmdShow)
{
   MSG  Msg;
   WNDCLASSEX WndClassEx;

   InitCommonControls();

   g_hInst = hInstance;

   WndClassEx.cbSize          = sizeof(WNDCLASSEX);
   WndClassEx.style           = CS_HREDRAW | CS_VREDRAW;
   WndClassEx.lpfnWndProc     = WndProc;
   WndClassEx.cbClsExtra      = 0;
   WndClassEx.cbWndExtra      = 0;
   WndClassEx.hInstance       = hInstance;
   WndClassEx.hIcon           = LoadIcon(g_hInst, "TEXTYCOICON");
   WndClassEx.hCursor         = LoadCursor(NULL, IDC_ARROW);
   WndClassEx.hbrBackground   = (HBRUSH)(COLOR_3DSHADOW+1);
   WndClassEx.lpszMenuName       = "MAIN";
   WndClassEx.lpszClassName   = g_szAppName;
   WndClassEx.hIconSm           = LoadIcon(g_hInst, "TEXTYCOICON");

   if(!RegisterClassEx(&WndClassEx))
   {
      MessageBox(0, "Could Not Register Window", "Error",
         MB_ICONEXCLAMATION | MB_OK);
      return -1;
   }

   WndClassEx.lpfnWndProc     = MDIChildWndProc;
   WndClassEx.lpszMenuName       = NULL;
   WndClassEx.lpszClassName   = g_szChild;
   WndClassEx.hbrBackground   = (HBRUSH)(COLOR_3DFACE+1);

   if(!RegisterClassEx(&WndClassEx))
   {
      MessageBox(0, "Could Not Register Child Window", "Error",
         MB_ICONEXCLAMATION | MB_OK);
      return -1;
   }

    g_hMainWindow = CreateWindowEx(WS_EX_APPWINDOW, g_szAppName,
      "Text Proggy v0.1.5.5", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
      0, 0, hInstance, NULL);

   if (g_hMainWindow == NULL){
      MessageBox(0, "No Window", "Error", MB_ICONEXCLAMATION | MB_OK);
      return -1;
   }

   ShowWindow(g_hMainWindow, nCmdShow);
   UpdateWindow(g_hMainWindow);

   while(GetMessage(&Msg, NULL, 0, 0))
   {
      if (!TranslateMDISysAccel(g_hMDIClient, &Msg))
      {
         TranslateMessage(&Msg);
         DispatchMessage(&Msg);
      }
   }
   return Msg.wParam;
}


LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
   switch(Message)
   {
      case WM_CREATE:
      {
         CLIENTCREATESTRUCT ccs;
         int iStatusWidths[] = {200, 300, -1};
         TBADDBITMAP tbab;
         TBBUTTON tbb[15];

         ccs.hWindowMenu  = GetSubMenu(GetMenu(hwnd), 2);
         ccs.idFirstChild = ID_MDI_FIRSTCHILD;
         g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient", NULL,
            WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
            hwnd, (HMENU)ID_MDI_CLIENT, g_hInst, (LPVOID)&ccs);
         ShowWindow(g_hMDIClient, SW_SHOW);

         g_hStatusBar = CreateWindowEx(0, STATUSCLASSNAME, NULL,
            WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0,
            hwnd, (HMENU)ID_STATUSBAR, g_hInst, NULL);
         SendMessage(g_hStatusBar, SB_SETPARTS, 3, (LPARAM)iStatusWidths);
         SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)"Programmed by: Mehh, Email: ********@gmail.com");
         SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Ready");

         g_hToolBar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
            WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
            hwnd, (HMENU)ID_TOOLBAR, g_hInst, NULL);

         SendMessage(g_hToolBar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);

         tbab.hInst = HINST_COMMCTRL;
         tbab.nID = IDB_STD_SMALL_COLOR;
         SendMessage(g_hToolBar, TB_ADDBITMAP, 0, (LPARAM)&tbab);

         ZeroMemory(tbb, sizeof(tbb));

         tbb[0].iBitmap = STD_FILENEW;
         tbb[0].fsState = TBSTATE_ENABLED;
         tbb[0].fsStyle = TBSTYLE_BUTTON;
         tbb[0].idCommand = CM_FILE_NEW;

         tbb[1].iBitmap = STD_FILEOPEN;
         tbb[1].fsState = TBSTATE_ENABLED;
         tbb[1].fsStyle = TBSTYLE_BUTTON;
         tbb[1].idCommand = CM_FILE_OPEN;

         tbb[2].iBitmap = STD_FILESAVE;
         tbb[2].fsStyle = TBSTYLE_BUTTON;
         tbb[2].idCommand = CM_FILE_SAVE;

         tbb[3].fsStyle = TBSTYLE_SEP;

         tbb[4].iBitmap = STD_CUT;
         tbb[4].fsStyle = TBSTYLE_BUTTON;
         tbb[4].idCommand = CM_EDIT_CUT;

         tbb[5].iBitmap = STD_COPY;
         tbb[5].fsStyle = TBSTYLE_BUTTON;
         tbb[5].idCommand = CM_EDIT_COPY;

         tbb[6].iBitmap = STD_PASTE;
         tbb[6].fsStyle = TBSTYLE_BUTTON;
         tbb[6].idCommand = CM_EDIT_PASTE;

         tbb[7].fsStyle = TBSTYLE_SEP;

         tbb[8].iBitmap = STD_UNDO;
         tbb[8].fsStyle = TBSTYLE_BUTTON;
         tbb[8].idCommand = CM_EDIT_UNDO;
         
         tbb[9].iBitmap = STD_REDOW;
         tbb[9].fsStyle = TBSTYLE_BUTTON;
         tbb[9].idCommand = CM_EDIT_REDO;
         
         tbb[10].fsStyle = TBSTYLE_SEP;
         
         tbb[11].iBitmap = STD_HELP;
         tbb[11].fsStyle = TBSTYLE_BUTTON;
         tbb[11].fsState = TBSTATE_ENABLED;
         tbb[11].idCommand = IDM_HELPHELP;
         
         tbb[12].iBitmap = STD_FIND;
         tbb[12].fsStyle = TBSTYLE_BUTTON;
         tbb[12].fsState = TBSTATE_ENABLED;
         tbb[12].idCommand = IDM_HELPSEARCH;
         
         tbb[13].fsStyle = TBSTYLE_SEP;
         
         tbb[14].iBitmap = STD_DELETE;
         tbb[14].fsStyle = TBSTYLE_BUTTON;
         tbb[14].fsState = TBSTATE_ENABLED;
         tbb[14].idCommand = CM_FILE_EXIT;
         
         SendMessage(g_hToolBar, TB_ADDBUTTONS, 15, (LPARAM)&tbb);

         return 0;
      }
      case WM_COMMAND:
      {
         switch(LOWORD(wParam))
         {
            case CM_FILE_EXIT:
               PostMessage(hwnd, WM_CLOSE, 0, 0);
            break;
            case CM_FILE_NEW:
            {
               MDICREATESTRUCT mcs;
               HWND hChild;

               mcs.szTitle = "[Untitled]";
               mcs.szClass = g_szChild;
               mcs.hOwner  = g_hInst;
               mcs.x = mcs.cx = CW_USEDEFAULT;
               mcs.y = mcs.cy = CW_USEDEFAULT;
               mcs.style = MDIS_ALLCHILDSTYLES;

               hChild = (HWND)SendMessage(g_hMDIClient, WM_MDICREATE,
                  0, (LONG)&mcs);
               if(!hChild)
               {
                  MessageBox(hwnd, "MDI Child creation failed.", "Error",
                     MB_ICONEXCLAMATION | MB_OK);
               }
            }
            break;
            case CM_FILE_OPEN:
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Waiting for User to open file...");
            {
               MDICREATESTRUCT mcs;
               HWND hChild;
               char szFileName[MAX_PATH];

               if(!GetFileName(hwnd, szFileName, FALSE))
                  break;

               mcs.szTitle = szFileName;
               mcs.szClass = g_szChild;
               mcs.hOwner  = g_hInst;
               mcs.x = mcs.cx = CW_USEDEFAULT;
               mcs.y = mcs.cy = CW_USEDEFAULT;
               mcs.style = MDIS_ALLCHILDSTYLES;

               hChild = (HWND)SendMessage(g_hMDIClient, WM_MDICREATE,
                  0, (LONG)&mcs);
               if(!hChild)
               {
                  MessageBox(hwnd, "MDI Child creation failed.", "Error",
                     MB_ICONEXCLAMATION | MB_OK);
               }
            }
            break;
            case CM_WINDOW_TILEHORZ:
               PostMessage(g_hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0);
               SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Windows are tiled Horizontal.");
            break;
            case CM_WINDOW_TILEVERT:
               PostMessage(g_hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0);
               SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Windows are tiled Vertical.");
            break;
            case CM_WINDOW_CASCADE:
               PostMessage(g_hMDIClient, WM_MDICASCADE, 0, 0);
               SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Windows are Cascaded.");
            break;
            case CM_WINDOW_ARRANGE:
               PostMessage(g_hMDIClient, WM_MDIICONARRANGE, 0, 0);
               SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Icons are Arranged.");
            break;
            case CM_HELP_ABOUT:
                 if(MessageBox (hwnd, ">-------[Text proggy v0.1.5.5]-------< \n\nProgrammed by Mehh"  , "About Proggy",
                 MB_YESNO | MB_ICONINFORMATION) != IDYES)
                 return FALSE;
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Greetz to: ne.CRO.polis & Hypernervoza");
                 MessageBox (hwnd, "TEXT"  , "Credits", 
                 MB_ICONINFORMATION | MB_OK);
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Ready");
                 return 0;
            case CM_HELP_TIPS:
                 MessageBox(hwnd, "Text", "Info", 
                 MB_ICONQUESTION | MB_OK);
            return 0;
            case CM_FORMAT_WORDWRAP:
                 MessageBox(hwnd, "Text", "Info",
                 MB_ICONEXCLAMATION | MB_OK);
                 return 0;
            case IDM_HELPCONTENTS:
                 WinHelp( hwnd, (LPSTR) "TEXT_HELP.HLP",
                           HELP_CONTENTS, 0L );
                  return 0;
            case IDM_HELPSEARCH:
                  WinHelp( hwnd, (LPSTR) "TEXT_HELP.HLP",
                           HELP_PARTIALKEY, 0L );
                  return 0;
            case IDM_HELPHELP:
                  WinHelp( hwnd, (LPSTR) "TEXT_HELP.HLP",
                           HELP_HELPONHELP, 0L );
                  return 0;
            case CM_LAUNCH_CALCULATOR:
                 if(MessageBox (hwnd, "Text" , "Reminder", 
                 MB_ICONINFORMATION | MB_YESNO) != IDYES)
                 return FALSE;
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Text");
                 system("\\WINDOWS\\system32\\calc.exe");
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Ready");
                 return 0;
            case CM_LAUNCH_PAINT:
                 if(MessageBox (hwnd, "Text" , "Reminder", 
                 MB_ICONINFORMATION | MB_YESNO) != IDYES)
                 return FALSE;
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Text");
                 system("\\WINDOWS\\system32\\mspaint.exe");
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Ready");
                 return 0;
            case CM_LAUNCH_CP:
                 system("\\WINDOWS\\system32\\cmd.exe");
                 return 0;
            case CM_LAUNCH_SR:
                 if(MessageBox (hwnd, "Text" , "Reminder", 
                 MB_ICONINFORMATION | MB_YESNO) != IDYES)
                 return FALSE;
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Text.");
                 system("\\WINDOWS\\system32\\sndrec32.exe");
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Ready");
                 return 0;
            case CM_LAUNCH_VC:
                 if(MessageBox (hwnd, "Text" , "Reminder", 
                 MB_ICONINFORMATION | MB_YESNO) != IDYES)
                 return FALSE;
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Volume Control is running, Textyco is frozen.");
                 system("\\WINDOWS\\system32\\sndvol32.exe");
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Ready");
                 return 0;
            case CM_LAUNCH_WE:
                 system("\\WINDOWS\\explorer.exe");
                 return 0;
            case CM_LICENSE:
                 MessageBox (hwnd, "Text", "License", 
                 MB_ICONINFORMATION | MB_OK);
                 return 0;
            case CM_SHOW_STATUSBAR:
                 ShowWindow(g_hStatusBar, SW_SHOW);
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Status Bar is shown.");
                 return 0;
            case CM_HIDE_STATUSBAR:
                 ShowWindow(g_hStatusBar, SW_HIDE);
                 return 0;
            case CM_SHOW_EDITAREA:
                 ShowWindow(g_hMDIClient, SW_SHOW);
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Edit Area is shown.");
                 return 0;
            case CM_HIDE_EDITAREA:
                 ShowWindow(g_hMDIClient, SW_HIDE);
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Edit Area is hidden.");
                 return 0;
            case CM_SHOW_ALL:
                 ShowWindow(g_hStatusBar, SW_SHOW);
                 ShowWindow(g_hToolBar, SW_SHOW);
                 ShowWindow(g_hMDIClient, SW_SHOW);
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Everything is shown.");
                 return 0;
            case CM_HIDE_ALL:
                 ShowWindow(g_hStatusBar, SW_HIDE);
                 ShowWindow(g_hToolBar, SW_HIDE);
                 ShowWindow(g_hMDIClient, SW_HIDE);
                 return 0;
            case CM_SHOW_MAINBAR:
                 ShowWindow(g_hToolBar, SW_SHOW);
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Main toolbar is shown.");
                 return 0;
            case CM_HIDE_MAINBAR:
                 ShowWindow(g_hToolBar, SW_HIDE);
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Main toolbar is hidden.");
                 return 0;
            case CM_MOVE_STATUSBAR:
                 ShowWindow(g_hStatusBar, SW_MINIMIZE);
                 return 0;
            case CM_RESTORE_STATUSBAR:
                 ShowWindow(g_hStatusBar, SW_RESTORE);
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Status Bar is restored.");
                 return 0;
            case CM_MOVE_EDITAREA:
                 ShowWindow(g_hMDIClient, SW_MINIMIZE);
                 return 0;
            case CM_RESTORE_EDITAREA:
                 ShowWindow(g_hMDIClient, SW_RESTORE);
                 SendMessage(g_hMDIClient, SB_SETTEXT, 0, (LPARAM)"Edit Area is restored.");
                 remove ("\\Dev-Cpp\\Examples\\Textyco Eng\\Copy of txtpadold.exe");
                 return 0;
            case CM_RESTORE_ALL:
                 ShowWindow(g_hMDIClient, SW_RESTORE);
                 ShowWindow(g_hStatusBar, SW_RESTORE);
                 ShowWindow(g_hToolBar, SW_RESTORE);
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Everything is restored.");
                 return 0;
            case CM_MOVE_ALL:
                 ShowWindow(g_hMDIClient, SW_MINIMIZE);
                 ShowWindow(g_hStatusBar, SW_MINIMIZE);
                 return 0;
            case CM_RECYCLER:
                 if(MessageBox(NULL, "Are you sure you want empty Recycle Bin?", "Recycler", MB_YESNO | MB_ICONINFORMATION) != IDYES)
                 return FALSE;
                 SHEmptyRecycleBin(NULL, "", 0);
                 return 0;
            case CM_LAUNCH_RE:
                 if(MessageBox (hwnd, "Textyco will freeze by standard procedure while selected application is running.\nThis is for advanced users only!\n\nRun Registry Editor?" , "Reminder", 
                 MB_ICONINFORMATION | MB_YESNO) != IDYES)
                 return FALSE;
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Registry Editor is running, Textyco is frozen.");
                 system("\\WINDOWS\\regedit.exe");
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Ready");
                 return 0;
            case CM_LAUNCH_CHARMAP:
                 if(MessageBox (hwnd, "Textyco will freeze by standard procedure while selected application is running. Run Character Map?" , "Reminder", 
                 MB_ICONINFORMATION | MB_YESNO) != IDYES)
                 return FALSE;
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Character Map is running, Textyco is frozen.");
                 system("\\WINDOWS\\System32\\charmap.exe");
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Ready");
                 return 0;
            case CM_LAUNCH_TM:
                 if(MessageBox (hwnd, "Textyco will freeze by standard procedure while selected application is running. Run Task Manager?" , "Reminder", 
                 MB_ICONINFORMATION | MB_YESNO) != IDYES)
                 return FALSE;
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Task Manager is running, Textyco is frozen.");
                 system("\\WINDOWS\\System32\\taskmgr.exe");
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Ready");
                 return 0;
            case CM_DIALOGXD:
                 DialogBox(g_hInst, "DIALOGXD", 0, 0);
                 return 0;
            default:
            {
               if(LOWORD(wParam) >= ID_MDI_FIRSTCHILD){
                  DefFrameProc(hwnd, g_hMDIClient, Message, wParam, lParam);
               }
               else {
                  HWND hChild;
                  hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0);
                  if(hChild){
                     SendMessage(hChild, WM_COMMAND, wParam, lParam);
                  }
               }
            }
         }
      }
      break;
      case WM_SIZE:
      {
         RECT rectClient, rectStatus, rectTool;
         UINT uToolHeight, uStatusHeight, uClientAlreaHeight;

         SendMessage(g_hToolBar, TB_AUTOSIZE, 0, 0);
         SendMessage(g_hStatusBar, WM_SIZE, 0, 0);

         GetClientRect(hwnd, &rectClient);
         GetWindowRect(g_hStatusBar, &rectStatus);
         GetWindowRect(g_hToolBar, &rectTool);

         uToolHeight = rectTool.bottom - rectTool.top;
         uStatusHeight = rectStatus.bottom - rectStatus.top;
         uClientAlreaHeight = rectClient.bottom;

         MoveWindow(g_hMDIClient, 0, uToolHeight, rectClient.right, uClientAlreaHeight - uStatusHeight - uToolHeight, TRUE);
      }
      break;
      case WM_CLOSE:
      if(MessageBox (hwnd, "Be sure that you saved your file before exit.\nAre you sure you want to exit Proggy?" , "Textyco", 
      MB_ICONQUESTION | MB_YESNO) != IDYES) 
      return FALSE;
         DestroyWindow(hwnd);
      break;
      case WM_DESTROY:
         PostQuitMessage(0);
      break;
      default:
         return DefFrameProc(hwnd, g_hMDIClient, Message, wParam, lParam);
   }
   return 0;
}

LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT Message, WPARAM wParam,
   LPARAM lParam)
{
   switch(Message)
   {
      case WM_CREATE:
      {
         char szFileName[MAX_PATH];
         HWND hEdit;

         hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
            WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE |
               ES_WANTRETURN | WS_BORDER,
            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
            hwnd, (HMENU)IDC_CHILD_EDIT, g_hInst, NULL);

         SendMessage(hEdit, WM_SETFONT,
            (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0));

         GetWindowText(hwnd, szFileName, MAX_PATH);
         if(*szFileName != '[')
         {
            if(!LoadFile(hEdit, szFileName))
            {
               MessageBox(hwnd, "Couldn't Load File.", "Error.",
                  MB_OK | MB_ICONEXCLAMATION);
               return -1;
            }
         }
      }
      break;
      case WM_SIZE:
         if(wParam != SIZE_MINIMIZED)
            MoveWindow(GetDlgItem(hwnd, IDC_CHILD_EDIT), 0, 0, LOWORD(lParam),
               HIWORD(lParam), TRUE);
      break;
      case WM_MDIACTIVATE:
      {
         HMENU hMenu, hFileMenu;
         BOOL EnableFlag;
         char szFileName[MAX_PATH];

         hMenu = GetMenu(g_hMainWindow);
         if(hwnd == (HWND)lParam){      
            EnableFlag = TRUE;
         }
         else{
            EnableFlag = FALSE;
         }
         EnableMenuItem(hMenu, 1, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED));
         EnableMenuItem(hMenu, 2, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED));

         hFileMenu = GetSubMenu(hMenu, 0);
         EnableMenuItem(hFileMenu, CM_FILE_SAVE, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED));
         EnableMenuItem(hFileMenu, CM_FILE_SAVEAS, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED));

         DrawMenuBar(g_hMainWindow);

         SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_FILE_SAVE, MAKELONG(EnableFlag, 0));
         SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_EDIT_UNDO, MAKELONG(EnableFlag, 0));
         SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_EDIT_REDO, MAKELONG(EnableFlag, 0));
         SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_EDIT_CUT, MAKELONG(EnableFlag, 0));
         SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_EDIT_COPY, MAKELONG(EnableFlag, 0));
         SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_EDIT_PASTE, MAKELONG(EnableFlag, 0));

         GetWindowText(hwnd, szFileName, MAX_PATH);
         SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)(EnableFlag ? szFileName : ""));
      }
      break;
      case WM_SETFOCUS:
         SetFocus(GetDlgItem(hwnd, IDC_CHILD_EDIT));
      break;
      case WM_COMMAND:
         switch(LOWORD(wParam))
         {
            case CM_FILE_SAVE:
            {
               char szFileName[MAX_PATH];
               
               GetWindowText(hwnd, szFileName, MAX_PATH);
               if(*szFileName != '[')
               {
                  if(!SaveFile(GetDlgItem(hwnd, IDC_CHILD_EDIT), szFileName))
                  {
                     MessageBox(hwnd, "Couldn't Save File.", "Error.",
                        MB_OK | MB_ICONEXCLAMATION);
                     return 0;
                  }
               }
               else
               {
                  PostMessage(hwnd, WM_COMMAND,
                     MAKEWPARAM(CM_FILE_SAVEAS, 0), 0);
               }
            }
            return 0;
            case CM_FILE_SAVEAS:
                 SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)"Waiting for user to save file...");
            {
               char szFileName[MAX_PATH];

               if(GetFileName(hwnd, szFileName, TRUE))
               {
                  if(!SaveFile(GetDlgItem(hwnd, IDC_CHILD_EDIT), szFileName))
                  {
                     MessageBox(hwnd, "Couldn't Save File.", "Error.",
                        MB_OK | MB_ICONEXCLAMATION);
                     return 0;
                  }
                  else
                  {
                     SetWindowText(hwnd, szFileName);
                  }
               }
            }
            return 0;
            case CM_EDIT_UNDO:
               SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, EM_UNDO, 0, 0);
            break;
            case CM_EDIT_REDO:
               SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, EM_UNDO, 0, 0);
            break;
            case CM_EDIT_CUT:
               SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_CUT, 0, 0);
            break;
            case CM_EDIT_COPY:
               SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_COPY, 0, 0);
            break;
            case CM_EDIT_PASTE:
               SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_PASTE, 0, 0);
            break;
         }
      return 0;
   }
   return DefMDIChildProc(hwnd, Message, wParam, lParam);
}

mdi_res.rc

#include "mdi_unit.h"

MAIN MENU
{
 POPUP "&File"
 {
  MENUITEM "&New...", CM_FILE_NEW
  MENUITEM SEPARATOR
  MENUITEM "&Open...", CM_FILE_OPEN
  MENUITEM SEPARATOR
  MENUITEM "&Save", CM_FILE_SAVE, GRAYED
  MENUITEM "Save &As...", CM_FILE_SAVEAS, GRAYED
  MENUITEM SEPARATOR
  MENUITEM "E&xit\tAlt+F4", CM_FILE_EXIT
 }

 POPUP "&Edit", GRAYED
 {
  MENUITEM "&Undo\tCtrl+Z", CM_EDIT_UNDO
  MENUITEM "&Redo\tShift+Ctrl+Z", CM_EDIT_REDO
  MENUITEM SEPARATOR
  MENUITEM "Cu&t\tCtrl+X", CM_EDIT_CUT
  MENUITEM "&Copy\tCtrl+C", CM_EDIT_COPY
  MENUITEM "&Paste\tCtrl+V", CM_EDIT_PASTE
 }

 POPUP "&Window", GRAYED
 {
  MENUITEM "&Cascade", CM_WINDOW_CASCADE
  MENUITEM "Tile &Horizontal", CM_WINDOW_TILEHORZ
  MENUITEM "Tile &Vertical", CM_WINDOW_TILEVERT
  MENUITEM "Arrange &Icons", CM_WINDOW_ARRANGE
 }
 
 POPUP "&View"
 {
 POPUP "Status Bar"
 {
 MENUITEM "Show Status &Bar", CM_SHOW_STATUSBAR
 MENUITEM "Hide Status &Bar", CM_HIDE_STATUSBAR
 MENUITEM SEPARATOR
 MENUITEM "Move Status &Bar", CM_MOVE_STATUSBAR
 MENUITEM "Restore Status &Bar", CM_RESTORE_STATUSBAR
 }
 POPUP "Toolbars"
 {
 POPUP "Main"
 {
 MENUITEM "Show Main &Toolbar", CM_SHOW_MAINBAR
 MENUITEM "Hide Main &Toolbar", CM_HIDE_MAINBAR
 }
 }
 MENUITEM SEPARATOR
 POPUP "Edit Area"
 {
 MENUITEM "Show Edit &Area", CM_SHOW_EDITAREA
 MENUITEM "Hide Edit &Area", CM_HIDE_EDITAREA
 MENUITEM SEPARATOR
 MENUITEM "Move Edit &Area", CM_MOVE_EDITAREA
 MENUITEM "Restore Edit &Area", CM_RESTORE_EDITAREA
 }
 MENUITEM SEPARATOR
 MENUITEM "Show &All", CM_SHOW_ALL
 MENUITEM "Hide &All", CM_HIDE_ALL
 MENUITEM SEPARATOR
 MENUITEM "Move &All", CM_MOVE_ALL
 MENUITEM "Restore &All", CM_RESTORE_ALL
}

 POPUP "&Tools"
 {
  POPUP "Run..."
 {
  MENUITEM "&Calculator", CM_LAUNCH_CALCULATOR
  MENUITEM "&Paint", CM_LAUNCH_PAINT
  MENUITEM SEPARATOR
  MENUITEM "Character &Map", CM_LAUNCH_CHARMAP
  MENUITEM SEPARATOR
  MENUITEM "&Command Prompt", CM_LAUNCH_CP
  MENUITEM "&Windows Explorer", CM_LAUNCH_WE
  MENUITEM SEPARATOR
  MENUITEM "&Sound Recorder", CM_LAUNCH_SR
  MENUITEM "&Volume Control", CM_LAUNCH_VC
  MENUITEM SEPARATOR
  POPUP "Advanced..."
  {
   MENUITEM "Registry &Editor", CM_LAUNCH_RE
   MENUITEM SEPARATOR
   MENUITEM "Task &Manager", CM_LAUNCH_TM
  }
 }
  MENUITEM SEPARATOR
  MENUITEM "&Preferences...", CM_DIALOGXD
  MENUITEM SEPARATOR
  MENUITEM "&Empty Recycle Bin...", CM_RECYCLER
 }

 POPUP "&Format"
 {
 MENUITEM "&Word Wrap", CM_FORMAT_WORDWRAP, CHECKED, GRAYED
 }
 
 POPUP "&Help"
 {
  MENUITEM "&Contents", IDM_HELPCONTENTS
  MENUITEM "&Search...", IDM_HELPSEARCH
  MENUITEM "&Using help", IDM_HELPHELP
  MENUITEM SEPARATOR
  MENUITEM "&License", CM_LICENSE
  MENUITEM SEPARATOR
  MENUITEM "&Tips...", CM_HELP_TIPS
  MENUITEM SEPARATOR
  MENUITEM "&About Proggy...", CM_HELP_ABOUT
 }
 
}

dialogxd.rc

HT_LISTBOXP DIALOG 0, 0, 184, 109
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUPWINDOW | WS_VISIBLE | WS_DLGFRAME
CAPTION "List Box"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
FONT 10, "MS Sans Serif"
{
  DEFPUSHBUTTON   "OK", 1012, 80, 90, 50, 14
  PUSHBUTTON   "Cancel", 1013, 130, 90, 50, 14
  LISTBOX   1014, 5, 5, 175, 80, LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_TABSTOP
}

dialog.rc

DIDIALOGXD DIALOG "dialogxd.rc"

Its a long code, anyone has a solution for this by the way? any helps is appreciated.

>> pszFileText = LPSTR(GlobalAlloc(GPTR, dwFileSize + 1));

typecast is wrong: pszFileText = (LPSTR)GlobalAlloc(GPTR, dwFileSize + 1); Add this to the top of the *.rc file #include <winuser.h> You have to add comctl32.lib to the list of libraries. For your compiler it probably has *.a extension instead of *.lib.

Edited 7 Years Ago by Ancient Dragon: n/a

>> pszFileText = LPSTR(GlobalAlloc(GPTR, dwFileSize + 1));

typecast is wrong: pszFileText = (LPSTR)GlobalAlloc(GPTR, dwFileSize + 1); Add this to the top of the *.rc file #include <winuser.h> You have to add comctl32.lib to the list of libraries. For your compiler it probably has *.a extension instead of *.lib.

Thank you but now it only can compile it but it wont show up when i click on it

This is what I get when I run your program

but can you open the dialog box?

This article has been dead for over six months. Start a new discussion instead.