|
you don't need to use #using "System.Windows.Forms.dll"
yust by adding namespace, you aotomaticly add references
Fritzables wrote: SendKeys::SendWait("%F");
The '%F' simulates the Alt-F to access the menu.
Dou you men like this:
menu1->Text = "&File"; // ALT-F
menu2->Text = "&Edit"; // ALT-E
menu3->Text = "E&xit"; // ALT-X
|
|
|
|
|
Ok..... I have now taken out the line:
<br />
#using "System.Windows.Forms.dll"<br />
And now just using:
<br />
using namespace System::Windows::Forms;<br />
But still when compiling I get the following errors:
<br />
: error C3083: 'Windows': the symbol to the left of a '::' must be a type<br />
: error C2039: 'Forms' : is not a member of 'System'<br />
: error C2871: 'Forms' : a namespace with this name does not exist<br />
Pete
|
|
|
|
|
Have you added a reference to the "System.Windows.Forms.dll" ?
If not, reference this dll in your project and then try compiling the code.
Hope this might help you.
Girish K
|
|
|
|
|
G'Day Girish,
Yea, I had that in my original code:
<br />
#using <System.Windows.Forms.dll><br />
and also had:
<br />
using namespace System::Windows::Forms;<br />
But I was told to take the top line out as the namespace will reference the DLL.
But when I compile either way I still get that same error code.
Pete
|
|
|
|
|
go to menu:
Project->(Your Project Name) Properties->Common Properties
On the right you will see references And you can click Add Reference.
Other oproblem coud be: Under General, look if you have Common Language Runtime Support. As long as you have with /clr
Third possible. You can have problem with a code. If so then try to add a comment to all includes.
If you have a problem with client, yust to be same make an test project. But this namespace would automaticly be in use
|
|
|
|
|
G'Day bsaksida,
Have a look at my reply to Girish......
Thanks for the hand on this.
Pete
|
|
|
|
|
Hi Pete,
I am not sure whether you got my query correctly.
Try this ,
Right click on the Project and Choose References. Then Add reference to "System.Windows.Forms.dll".
Try to compile your code after you have added this line
using namespace System::Windows::Forms;
Compile and check if it works.
If this does not work, then please post your code snippet..
Thanks & Regards,
Girish K
|
|
|
|
|
G'Day Girish,
Yep ya right.... thought you meant #using
You know us Aussies.... a bit slow
Thanks for the tip off and will try again in the morn when I get back to work.
Take care mate and have a good one.
Pete
|
|
|
|
|
Hey Girish,
I have just tried your suggestion - and I am back up and running.
Thanks again and have a great Xmas.
Pete
|
|
|
|
|
Great !!!
You too have a great X'Mas ...
Regards,
Girish
|
|
|
|
|
Hi,
I am using the copiled HTML help for my project. Earlier it was Winhelp. I am calling the HtmlHelp API as below from my code:
HtmlHelp (m_hWnd, "POM.chm", HH_HELP_CONTEXT, lHelpID);
here lHelpID is the mapid of my text/edit box for which i want to open help.
The problem here is when I use F1 key to open help for two diffrent text box (say FirstName and latname text boxes) it open the help for one and not for other textbox. But in help file the help tags for both textboxes are set up and directed to same topic.
Can anyone please help if they have encountered similar problem?
|
|
|
|
|
Hi all,
I wrote an application in VS2K5 using CLI, and when I copy the application to another computer and try to run it i get the folloing error:
(Please note the computer has .Net Framework on it)
Error Msg:
"The application has failed to start because the application configuration is incorrect. Reinstalling the application may fix the problem"
Can any one help ???
The only programmers that are better than C programmers are those who code in 1's and 0's.....
 Programm3r
|
|
|
|
|
Hi,
I am new to c++ and I will use it in my thesis on image processing.
I wrote a piece of code to read a ppm image file. in order to read the magic number (the number indicating the type of the image file whether it is ppm, bmp, jpeg or etc. this magic number is in the header section of the image) i create a char pointer magicNumber:
char *magicNumber;<br />
magicNumber = new char[2];
and pass it into the function PPMreadHeader. My intent is to fill the pointer inside the function and write the magicnumber in the console outside the function.
i have an array in the PPMreadHeader fuinction in order to read the file line by line. I have a local char pointer "word":
<br />
char line[255];<br />
char * word;
when i read the magicnumber (it is "P6" for ppm files) i assign it to the local pointer word:
word=line;
if i try to write the magic number in the function using the local pointer:
cout<<word<<endl;
there is no problem, it writes p6 to the console. however, if i first copy the word into the magicnumber pointer that i create in the main function:
*magicNumber=*word;<br />
*(magicNumber+1)=*(word+1);
and then try to print out the pointer to the consolelike below:
cout<<"magicNumber: "<<magicNumber<<endl;
then it writes:
magicNumber:P6ııııİİ
which not i want. it writes the p6 which is what i want to write to the console, but it writes more than p6. within the function when i write the local pointer "word" it just writes the P6, nothing more. Could you please help me on this.
You may advise other alternatives to write the magic number on to the console but even you do this, i still want to learn what is wrong with my coding. i spent a lot of time on this and i could not fix it.
Thank you in advance.
|
|
|
|
|
Did you read this post: The C++ / CLI is for managed and mixed-mode C++ programming only
you can find it on the top of first page of (Managed) C++/CLI.
This question shoud be in Visual C++ / MFC
|
|
|
|
|
I am using vs05
Thread ^thd = gcnew Thread(gcnew ThreadStart(CountTime));
error:
Error 1 error C3867: 'test::mainForm::CountTime': function call missing argument list; use '&test::mainForm::CountTime' to create a pointer to member c:\projects\test\mainForm.h 445
Error 2 error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s) c:\projects\test\mainForm.h 445
I can't find any correct info in help.
ps: I already checked Codeproject, but all articles are about VB.NET and C#
|
|
|
|
|
|
thanks it worked. One of my tries was exactly same expect it had CountTime(), but it shoud CountTime without ()
|
|
|
|
|
Read the error message, it's telling you what's wrong
use '&test::mainForm::CountTime' to create a pointer to member
|
|
|
|
|
I'm playing with this for first time. Anyhoot.. in the output its telling me that the leak occured in crtdbg.h instead of Test.h. Is this normal behavior?
<br />
#define _CRTDBG_MAP_ALLOC<br />
#include <stdlib.h><br />
#include <crtdbg.h><br />
<br />
#include "Test.h"
<br />
int main()<br />
{<br />
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );<br />
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );<br />
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );<br />
_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );<br />
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );<br />
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );<br />
<br />
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );<br />
<br />
<br />
<br />
<br />
<br />
_ASSERT(false);
<br />
int * leakyInt = new int;
<br />
Test test;
<br />
return 0;<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
|
|
|
|
|
This is the C++/CLI forum. You should post your question in the MFC/Visual C++ forum to receiver your request answer.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
What if you add this (in your Test.h)
#ifndef TEST
#define TEST
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
class Test
{
...
|
|
|
|
|
yep that works. had to include another header in main.cpp to get that DEBUG_NEW thing.
<br />
#ifdef _DEBUG<br />
#define _AFXDLL<br />
#include <afx.h><br />
#define new DEBUG_NEW<br />
#endif<br />
|
|
|
|
|
Hi guys,
I think I need some serious painkillers on this!
Short version:
Can anybody explain in details how to expose a C# WinForms Control as ActiveX control. Either via hosting it in a MFC ActiveX control or by implementing it completely in C# (implementing all interfaces, registration/unregistration stuff, events).
Perhaps somebody has a template project for this problem where I just can drop in my Windows Forms Control and is willing to share it with me and the others (sounds like XMas, I know).
Bloody details:
We have a large client application with lots of legacy code that implements an ActiveX container. So you can add e.g. GUI components by providing new ActiveX controls. Since we have almost year 2007 we want to develop new GUI components with Windows Forms instead of the existing MFC/OWL stuff (yes! OWL! ). We recently migrated to Visual Studio 2005 (.NET 2.0).
As far as I can see there are 2 main approaches:
(Approach 1) Use of a MFC ActiveX control for hosting the Windows Forms control and use the new MFC 8.0 template classes CWinFormsDialog[^] or CWinFormsView[^] for adding the WinForms control to a CDialog/CView.
(Approach 2) Implement all necessary COM interfaces completely in C# and make them visible to COM and do the extra COM registration/unregistration stuff as explained here[^]. So the resulting component would be completely written in C# with no other languages involved. Furthermore we have about half a dozen COM interfaces for communication between the client and the ActiveX component. These interfaces must be implemented too. Sounds like very much more work than approach one.
So we decided to follow approach one - hosting a WinForms control within a MFC ActiveX control. What a pain until now!
This is what we did (following the MSDN examples[^]):
(1) Created an "empty" MFC ActiveX control, with all of our COM interfaces, showing an empty CDialog. Works flawlessly when added to the client application or to the ActiveX Control Test Container.
(2) Enabled Common Language Runtime Support (/clr) for the project. After fixing some compiler warnings the project compiles fine to MSIL.
( #1) Here is already the first major problem: When the project is started after '/clr' is activated, Visual Studio 2005 locks up completely while loading the CLR DLLs (e.g. 'mscoree.dll', 'mscorwks.dll'). There is no error message or crash, but VS2005 hangs infinitely and the only thing to do is killing the 'devenv.exe' process. Why is this? But it's possible to start the application regularly! Only when started via VS2005 it hangs. The ActiveX still shows up correctly when the application is not launched via VS2005.
(3) Since I found no solution for this problem I sighed and added a CWinFormsControl member to the "empty" CDialog as described in the MSDN example here[^] (which works by the way perfectly when used in a stand alone dialog application). I tried two variants:
CWinFormsControl<WinFormsCtrl::UserControl1> m_WinFormsCtrl;
CWinFormsControl<System::Windows::Forms::LinkLabel> m_WinFormsCtrl; The result was the same in both cases:
( #2) When the ActiveX is about to be displayed it crashes in 'CWinFormsControl<TManagedControl>::InternalCreateManagedControl' (<VS2005-install-path>\vc\atlmfc\include\afxwinforms.inl). Output window says: A first chance exception of type 'System.AccessViolationException' occurred in <MyActiveX>.OCX
I got this information by attaching to the application process with VS2005 when the application is already running.
I read several threads where members of the Visual Studio Team and MVP's are saying that MFC 7.1/8.0 are officially supported unmanaged hosts for Windows Forms controls, just like Internet Explorer. But it seems not to apply for MFC ActiveX controls!?
cheers,
mykel
If they give you lined paper, write the other way!
|
|
|
|
|
C'mon... doesn't anybody have experience with hosting WinForms controls inside MFC ActiveX controls?
There must be lots of large "legacy" applications out there which implement an ActiveX container for (GUI) extensions.
Any help is appreciated, even comments like "Careful, you'll likely get burned using this approach, because ..."
cheers,
mykel
If they give you lined paper, write the other way!
|
|
|
|
|
I woud like an example to override,
ListView::set_DoubleBuffered() (Currently is Protected)
Thanks in advance
ps: I had already look on CP, but found nothing.
|
|
|
|