Problem to use windows.h in .Net Form application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

We need to use windows.h in a .net Form application, but somehow the function Message::Show(S"any string") no long compiled after we included windows.h file. and it generated following message:

error C2653: 'MessageBoxA' : is not a class or namespace name
error C2660: 'System::Windows::Forms::Control::Show' : function does not take 1 arguments

Is there anybody know how to solve the confliction problem. Thank!

Frank Wang
 
Hi, Igor:

Thank you very much for your suggestion, after undefine MessageBox, I can use MessageBox::Show in my .net form application .

You are an expert in this field, I have another question. After my form user inter face head file (from1.h) grows up to 1000 lines, it became extramely slow when I switched between source code and UI design interface. (takes about 30 seconds on a 2.8G CPU and 1G Memory Dell machine). Do you or anybody have any suggestion on this issue for the VC++ .net 7.1 compiler?

I didn't notice any delay for VC++ 6.0 when I switched between UI resource edit and source code thpugh.

Thanks again for your valid suggestion and helps.


Frank
 
Hi Frank.

Sorry for the delay, this took a while to track down. This is a known issue and is discussed in this KB Article - http://support.microsoft.com/default.aspx?scid=kb;EN-US;829318.

Regards,
Igor Zinkovsky [MSFT]
Visual Studio Build/Release Team

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm


Hi, Igor:

I have about 150 controls, most of them are labels. Only when the form1.h source code is changed in the source code editor window, then it will take long time to switch back to UI design view. The slow response also happened when I first open the porject, it also takes about 30 seconds to load the source code and UI.
Also, does this problem occur when you are switching from code to design view >with designer already open? or did you not have the designer open at all?

Yes, it only happens when I switch from code editor to UI design view after I change the source code of that UI interface.

Do you think it will be helpful,if I use old VC++ 6.0 style with head file with defination only and inplements the function detail in the *.cpp file. With .net IDE, it looks like prefer to put both defination and implementation in the same head file. If this is the reason do you know how to reset the IDE and make double click on any control on UI to point to the function block in *.cpp code.

Thanks you very much for your information and I am looking forward your further suggestions.

Best regard
Frank



Igor Zinkovsky said:
Hi Frank.

Can you please specify the number of controls that you have on your form?

Also, does this problem occur when you are switching from code to design view with designer already open? or did you not have the designer open at all?

Regards,
Igor Zinkovsky [MSFT]
Visual Studio Build/Release Team


This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm


Hi, Igor:

Thank you very much for your suggestion, after undefine MessageBox, I can use MessageBox::Show in my .net form application .

You are an expert in this field, I have another question. After my form user inter face head file (from1.h) grows up to 1000 lines, it became extramely slow when I switched between source code and UI design interface. (takes about 30 seconds on a 2.8G CPU and 1G Memory Dell machine). Do you or anybody have any suggestion on this issue for the VC++ .net 7.1 compiler?

I didn't notice any delay for VC++ 6.0 when I switched between UI resource edit and source code thpugh.

Thanks again for your valid suggestion and helps.


Frank





:

Hi Frank.

What happens is .NET MessageBox is replaced by preprocessor to MessageBoxA, defined by a macro in windows.h. To fix it - undefine the macro after your '#include <windows.h>':

#undef MessageBox

Hope this helps.
Igor Zinkovsky,
Visual Studio Build/Release Team


This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm


:

We need to use windows.h in a .net Form application, but somehow the function Message::Show(S"any string") no long compiled after we included windows.h file. and it generated following message:

error C2653: 'MessageBoxA' : is not a class or namespace name
error C2660: 'System::Windows::Forms::Control::Show' : function does not take 1 arguments

Is there anybody know how to solve the confliction problem. Thank!

Frank Wang
 
Back
Top