Solved

Dialog-based vs. SDI: VC++

Posted on 2001-06-25
7
640 Views
Last Modified: 2011-10-03
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.
0
Comment
Question by:ljaques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6225768
The dialog base framework doesn't come with Menu support, and it's harder to add database support for it.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6225775
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.
0
 
LVL 1

Expert Comment

by:ua1zcl
ID: 6226029
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); }
 }
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:Axter
ID: 6226041
>>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.
0
 
LVL 1

Expert Comment

by:ua1zcl
ID: 6226059
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"
......
0
 
LVL 1

Expert Comment

by:ua1zcl
ID: 6226069
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); }
 }
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 6226081
The choice of which framework to be used (dialog/SDI/MDI) is dicatated by the interface the application needs to present to the user.  You need to consider what the user will be doing and how they will be doing.  Then there should be no problem deciding between these options.  You migyht want to consult "The Windows Interface Guidlines for Software Desing" by Microsoft or "The Human Interface Guidelines".

The first questiohn to ask yourself is will the applicaiton be document based?  i.e. will the user be able to open and close files associated with the program.  for example a word processor, a paint program, a spread sheet are all document based.  They work on documents selected by the user.   However programs like calculators, accounting packages, simulators (maybe), games (maybe) are not document oriented.  The used does not interact with them in associates with documents/files.  (files might be used by the program, but the user does not "see" an interface where they are working with particular files.)  

If the interface is not document based, then the dialog framework is almost certainly appropriate.

If the interface is document based then you will want to use SDI/MDI or an MDI alternative.  You probably don't want SDI.  SDI is very restrictive to the user.  They may work on only one document at a time.  For some applications this might not be a problem, and might even be appropriate, but usually not.

Most likely you want MDI or an MDI alternative. These allow the user to wrok on more than one document at a time.  This tends to be best for users.  Then can be working on one task and switch to another without saving their work and loosing the place.  They can copy information from one documemtn to another or compare documents etc.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question