Solved

microsoft visual c++ 6.0 correct way to remove items from resources

Posted on 2009-05-20
2
425 Views
Last Modified: 2012-06-22
i would like to know the correct way to remove items from a form or a dialog.

I´ve been asigned to transform a visual 6 proyect and i wold like to know how to delete a hole group of buttons. What Ì´ve done is just hide them:
      GetDlgItem(IDC_STATIC1)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_LBL1)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_LBL8)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_LBL6)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_LBL7)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_STATIC_TURNO)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_EDIT_PLAYA)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_DTPICKER_FECHA)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_DTPICKER_HORA_DESDE)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_DTPICKER_HORA_HASTA)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_EDIT_TURNO)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_LBL3)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_COMBO_PEAJISTA)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_TIPO_VEHICULO)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_TIPO_VEHICULO2)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_COMBO_TIPO_VEHIC)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_STATIC_IMPORTE_TRANSITO)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_IMPORTE)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_GRID_LIGEROS)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_COMBO_ID_PEAJISTAS)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_LBL2)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_COMBO_VIA)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_BUTTON_GENERAR)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_STATIC2)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_GRID_RESULTADOS)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_GRID_TOTAL_RESULTADO)->ShowWindow(SW_HIDE);
      GetDlgItem(IDC_LOGO_CONCESIONARIA)->ShowWindow(SW_HIDE);

but now i cant redesign from the resource view because its full of these itmes, and if i delete them i get an error from the oninitialupdate MFC function.

0
Comment
Question by:perezthomson
  • 2
2 Comments
 
LVL 2

Expert Comment

by:Gregdo
Comment Utility
If you want to actually delete these items, then remove any code that refers to them:

1. Delete all the GetDialogItem() function calls above and any other code that refers to the controls that you want to delete.
2. Using the resource editor, remove the controls that you no longer need.

Check that it still builds and works.

3. Clean up the Resource.h header (or other header containing all the #defines) by removing the definitions for all the controls that you deleted.  Be aware that sometimes the same #defines can be used for multiple resources, so even though you removed them from this dialog, the #define might still be needed by another.
0
 
LVL 2

Accepted Solution

by:
Gregdo earned 125 total points
Comment Utility
I should also add that if my understanding of what you are doing is correct, the reason that you get the error in OnInitialUpdate() is that you removed the controls from the resource, but your code still refers to them.  Once you remove them from the dialog, you can no longer call GetDlgItem() as they are not there and will get errors.

If physically removing them is what you really want (not just hiding them), then the procedure above should fix the problem.
0

Featured Post

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

Join & Write a Comment

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

8 Experts available now in Live!

Get 1:1 Help Now