Solved

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

Posted on 2009-05-20
2
431 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
ID: 24437145
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
ID: 24437167
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 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