Solved

Dialog-based vs. SDI: VC++

Posted on 2001-06-25
7
607 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now