Link to home
Start Free TrialLog in
Avatar of ljaques
ljaques

asked on

Dialog-based vs. SDI: VC++

I am trying to figure out the advantages and disadvantages to Dialog-based and SDI frameworks of Visual C++ 6.

I am just beginning to use VC++ and it certainly isn't as polished as VB.  Under VB I always used regular forms to create whatever I needed.  There was no need to use SDI or MDI.  I've messed around in VC++ and have been able to place down toolbar controls, and status bar controls onto my Dialog based form but for menus, I've been unable to get accelerator keys to work under it.  How do I get accelerator keys to function under Dialog based mode in VC++?  

What are all the limitations to using the Dialog based frameworks?

Thanks.
Avatar of Axter
Axter
Flag of United States of America image

The dialog base framework doesn't come with Menu support, and it's harder to add database support for it.
Also without the document/view architecture support, it's harder to setup your application for opening and closeing  files.
It's also harder to add ActiveX support, and Automation.

If you have a simple applications that does not require menus, opening and closeing documents, ActiveX, and database support, a Dialog base application would be the better choice.

It's easier to setup, initialize, and debug.
Avatar of ua1zcl
ua1zcl

This is pice of WinMain in dialog based app where accelerators used and menu also, but no toolbar. I never
use it in my simple applications, but probably it,s
possible also.

  wcl.hInstance=hInst;
  wcl.lpszClassName=szHostName;
  wcl.lpfnWndProc=Dlg1Proc;
  wcl.style=0;
  wcl.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1));
  wcl.hCursor=LoadCursor(NULL,IDC_ARROW);
  wcl.lpszMenuName= "IDM_MENU1";
  wcl.cbClsExtra=IDD_DIALOG1;
  wcl.cbWndExtra=DLGWINDOWEXTRA ;
  wcl.hbrBackground= (HBRUSH)GetStockObject(LTGRAY_BRUSH);
  if(!RegisterClass (&wcl))return 0;
  // in .rc file allocated menu IDM_MENU1 and
  // accelerators IDM_MENU1 also
  hAccel= LoadAccelerators(hInst,MAKEINTRESOURCE(IDM_MENU1));
  hwnd= CreateDialog(hInst,MAKEINTRESOURCE(IDD_DIALOG1), hInst,0);
  while (GetMessage (&msg,NULL,0,0))
 {
  if( !TranslateAccelerator (hwnd,hAccel, &msg))
     { TranslateMessage (&msg);DispatchMessage (&msg); }
 }
>>never use it in my simple applications, but probably
>>it,s possible also.
It's possible to add almost all the stuff that is in the SDI.
The difference is that the SDI already comes with the support, and in the Dialog App, you have to add it.
Forgot, plase not forget to define a class string in dialog template.
//as a text in rc file it looks:
IDD_DIALOG1 DIALOGEX 0, 0, 309, 73
.....
CLASS "Some_your_class_name"
......
This is pice of WinMain in dialog based app where accelerators used and menu also, but no toolbar. I never
use it in my simple applications, but probably it,s
possible also.

  wcl.hInstance=hInst;
  wcl.lpszClassName=szHostName;
  wcl.lpfnWndProc=Dlg1Proc;
  wcl.style=0;
  wcl.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1));
  wcl.hCursor=LoadCursor(NULL,IDC_ARROW);
  wcl.lpszMenuName= "IDM_MENU1";
  wcl.cbClsExtra=IDD_DIALOG1;
  wcl.cbWndExtra=DLGWINDOWEXTRA ;
  wcl.hbrBackground= (HBRUSH)GetStockObject(LTGRAY_BRUSH);
  if(!RegisterClass (&wcl))return 0;
  // in .rc file allocated menu IDM_MENU1 and
  // accelerators IDM_MENU1 also
  hAccel= LoadAccelerators(hInst,MAKEINTRESOURCE(IDM_MENU1));
  hwnd= CreateDialog(hInst,MAKEINTRESOURCE(IDD_DIALOG1), hInst,0);
  while (GetMessage (&msg,NULL,0,0))
 {
  if( !TranslateAccelerator (hwnd,hAccel, &msg))
     { TranslateMessage (&msg);DispatchMessage (&msg); }
 }
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial