Solved

Dialog-based vs. SDI: VC++

Posted on 2001-06-25
7
616 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

776 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