Solved

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

Posted on 2009-05-20
2
430 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
64 bit versus 32 bit systems 2 118
preprocessor definition in visual studio 2 181
Calling a DLL from CSharp --  How? 4 61
c++ how to tell if the progra is ctl or mfc atl ect 6 63
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

17 Experts available now in Live!

Get 1:1 Help Now