|
Guys,
I'm trying a little test app in C++. I added a button and an event handler for this button.
I'm creating a test app that has to call some dll functions in late binding. Although I have done this before I tried to do a simple AfxMessageBox just to get the hang of it again. And it fails (yes this line: AfxMessageBox("Test"); fails. Even CString test = "My test here."; fails.)
so what did I forget? (I made a MFC app via the wizard, it gave me an error when adding the control variable for the button, but the rest it did just fine). MSDN says I have to do it like this. (and my memory, pray to God it didn't fail me, says so too;P)
the error message I get is :
Error 1 error C2440: 'initializing' : cannot convert from 'const char [9]' to 'ATL::CSimpleStringT<BaseType>' d:\projects\projects c++\loaddlltest\loaddlltest\loaddlltestdlg.cpp 92
tnx...
[MODIFIED]It doesn't work in 2005, it does work in 6.0 ...[/MODIFIED]
V.
If I don't see you in this world, I'll see you in the next one... And don't be late. (Jimi Hendrix)
|
|
|
|
|
AfxMessageBox(_T("Test"));
CString test = _T("My test here.");
led mike
|
|
|
|
|
works idd, I'll have to look up why some day .
tnx
|
|
|
|
|
I think it is just because the default project settings in VS2005 is UNICODE.
led mike
|
|
|
|
|
BOOL WriteFile(
HANDLE hFile, // handle to file to write to
LPCVOID lpBuffer, // pointer to data to write to file
DWORD nNumberOfBytesToWrite, // number of bytes to write
LPDWORD lpNumberOfBytesWritten, // pointer to number of bytes written
LPOVERLAPPED lpOverlapped // pointer to structure for overlapped I/O
);
When using this function and it's return false (failed) can i rely on lpNumberOfBytesWritten value?
(no answer in MSDN)
|
|
|
|
|
g_sasha wrote: (no answer in MSDN)
Really? In the documentation [^]it says:
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
led mike
|
|
|
|
|
I asking something else, Can i rely on LPDWORD lpNumberOfBytesWritten,
parameter in case of failure
|
|
|
|
|
g_sasha wrote: in case of failure
don't you think that might depend on what the error from GetLastError is? Why have you not posted the Error information?
led mike
|
|
|
|
|
There is no error (yet), i dont think it's depend on GetLastError, i think it's should be just yes/no answer.
Can you think of example where it may be depend on error ?
|
|
|
|
|
Probably a bad idea. And you're asking in the wrong forum
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
Hi all,
I am writing a console app which will in turn run a windows application then simulate sending keyboard command to the application.
I have been able to run the app and get it's handle and all that - every thing here is fine.
To issue keyboard command I will have to use the
SendKeys::SendWait("%F");
The '%F' simulates the Alt-F to access the menu.
Seeing that SendKeys is a member of the System::Windows::Form namespace I have to include this in my code, which I have done like this:
<br />
#using "System.Windows.Forms.dll"<br />
using namespace System::Windows::Forms;<br />
When I then compile the code, I get the following errors:
: error C3083: 'Windows': the symbol to the left of a '::' must be a type
: error C2039: 'Forms' : is not a member of 'System'
: error C2871: 'Forms' : a namespace with this name does not exist
: error C3083: 'Windows': the symbol to the left of a '::' must be a type
: error C3083: 'Forms': the symbol to the left of a '::' must be a type
: error C3083: 'SendKeys': the symbol to the left of a '::' must be a type
: error C2039: 'SendWait' : is not a member of 'System'
: error C3861: 'SendWait': identifier not found
So, what have I done wrong and how is this rectified ??
Pete
PS: Writing with VC++ 2005
|
|
|
|
|
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.
|
|
|
|