|
Zed wrote:
in front of #include "wincrypt.h". or "stdafx.h" if your project has it
Never ever include something in front of "stdafx.h"!
It is ignored after the preparation of the precompiled headers.
Either include in "stdafx.h" or after "stdafx.h".
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
yes, i know that.
what i meant was: include wtypes.h in front of wincrypt.h, or stdafx.h in front of wincrypt.h.
sorry for misunderstanding
|
|
|
|
|
That worked, thanks.
-Nick Parker
|
|
|
|
|
After converted the application from VC++ to .NET C++, I want to add a resource to the project. From the Project menu, I selected Add Resource. An error message popped up: error RC2135: file not found: MENU
I clicked OK and got another one: error RC2135: file not found: POPUP
What should I fix?
-Elizabeth
Eilzabeth
|
|
|
|
|
I have just converted an application from VC++6 to .NET C++. But I can not find the Dialog resource from the CDialog drived class in .NET. In VC++, I can get to the dialog resource from the Wizard Bar easily be scrolling down the member list. Where can I find it?
-Elizabeth
Eilzabeth
|
|
|
|
|
Hi I am trying to write data to the serial port using the windows api. I can write successfully by using a normal C style string with the MFC wrapper I wrote(with help from this site!) it goes something like this
void CSerComPort::WriteData(char* cData,DWORD dwBufferSize)
{
DWORD dwBytesWritten;
if(!WriteFile(m_ComPortHndl,cData,dwBufferSize,&dwBytesWritten,NULL))
; //throw exception for wrong write
else;// ASSERT(dwBytesWritten == sizeof(dwData));
}
works fine when i declare something like
char dwdata[]="test string";
But Ideally i would like to read data in from an edit box and this variable is of type CString, I have tried to use the member function GetBuffer which seems to be ok but when I pass GetLength as the second parameter it says I can't convert between int and unsigned long. Is there a standard way to do this, or would I be better rewriting the WriteData function? Please bear with me I am quite new to windows programming but I would like to know if there is a standard way to achieve this. Thanks
Andy
|
|
|
|
|
// I am asuming no UNICODE is involved.
// This should work, since LPTSTR is defined as char*
CString csData;
GetDlgItemText(IDC_TEXTSTRING, csData);
WriteData( LPCTSTR(csData),(DWORD)csData.GetLength() );
// Here are some more options
// If using C
char szBuffer[512];
int nLen = GetDlgItemText(hDlg, IDC_TEXTSTRING, szBuffer, sizeof(szBuffer));
WriteData( szBuffer,(DWORD)nLen );
// If using MFC
int nLen = GetDlgItemText(IDC_TEXTSTRING, szBuffer, sizeof(szBuffer));
WriteData( szBuffer,(DWORD)nLen );
// Else If using MFCs CString
CString csData;
GetDlgItemText(IDC_TEXTSTRING, csData);
// Then
WriteData( LPCTSTR(csData),(DWORD)csData.GetLength() );
// or
const char* pszData = csData.GetBuffer(csData.GetLength());
WriteData( pszData ,(DWORD)csData.GetLength() );
csData.ReleaseBuffer();
// or
WriteData( csData.LockBuffer(),(DWORD)csData.GetLength() );
csData.UnlockBuffer();
Trust in the code Luke. Yea right!
|
|
|
|
|
Conversion from CString to char* is simple.
For example,
CString str = "test string;
then you should write
WriteFile(m_ComPortHndl,(char*)(LPCTSTR) str, str.GetLength(), &dwBytesWritten,NULL)
C.R.Naik
|
|
|
|
|
|
Thanks for the help guys, I appreciate it
Andy
|
|
|
|
|
i wrote a html control that is hosted in an html page (in an explorer bar). how do i get the address of the page that's hosted in that main internet explorer?
thanks
melinda
|
|
|
|
|
It would be helpful to show the route I've been taking:
CComPtr<idispatch> spDisp;
hr = m_spBrowser->get_Document( &spDisp );
CComPtr<ihtmldocument2> spDoc2;
hr = spDisp->QueryInterface( &spDoc2 );
CComPtr<ihtmlwindow2> spWindow;
hr = spDoc2->get_parentWindow( &spWindow );
spDoc2 = NULL;
spWindow->get_document( &spDoc2 );
CComBSTR bstrParentUrl;
spDoc2->get_URL( &bstrParentUrl );
In bstrParentUrl I get a bizarre value like "res//C:\DOCUMEN~1\...." I've tried many other approaches and either get an empty string or this value.
Thanks
Melinda.
|
|
|
|
|
OK, so I have this application with some modless dialogs here and there. I want to catch when the user presses Ctrl-Z, Ctrl+Y, etc. from whatever modeless dialog may be active. How can I accomplish this? Any suggestions?
[edit] I guess what I really want is to create a message handler for a keyboard shortcut. [/edit]
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Look up "Keyboard Accelerators" in MSDN. I don't know if it will help you, since you have all those dialog boxes, but it's a start.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
yea, that's what im playing with now.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
A "global catcher" can be implemented only either in the Main message loop (MFC provides CWinApp::PreTranslateMessage for that), or, if you don#t have access to such a mechanism, by a windows hook.
(Hooks should be used only if absolutely necessary, though)
The Typical message loop looks like this:
while (GetMessage(&msg,...))
{
TranslateMessage(&msg);
DispatchMessage();
}
the MFC message loop looks (more or less) like this:
while (GetMessage())
{
if (!PreTranslateMessage(msg)) {
TranslataeMessage(&msg);
DispatchMessage(&msg);
}
}
You can implement a similar method if you're not using MFC.
Italian is a beautiful language. amare means to love, and amara bitter.
sighist | Agile Programming | doxygen
|
|
|
|
|
Another solution is TranslateAccelerator().
HACCEL hSomeAcc = ::LoadAccelerators(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDR_SOME_ACCELERATOR));
PreTranslateMessage()
{
...
if(::TranslateAccelerator(m_hWnd, hSomeAcc, pMsg))
return(TRUE);
...
return FALSE;
}
Kuphryn
|
|
|
|
|
sweet! I was looking into this before I left for the day. I will try it tomorrow. Thanx!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I'm using the ping class listed in network/internet section of CP. When I compile my app in debug mode it works great. When I compile it in release mode I get the following error:
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxcmn2.inl(293) : error C2084: function '__thiscall CIPAddressCtrl::CIPAddressCtrl(void)' already has a body
Both have the same settings. I'm not sure what this error means, can someone give some insight to this.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
for some reason my application fails to start and gets
this message ...
Debug Assertion failed!
Program: blah blah blah
File: objcore.cpp
Line 43
When I rebuild all I see warnings C786: '...' : identifier was truncated to '255' characters in the debug information.
I really don't care about the debug information.
Why would debug information cause my application to fail?
Please help!
|
|
|
|
|
You've got bugs ...
(assuming it's a MFC application)
When the application crashes right at the beginning, it can be that one of the main resource ID or resource is corrupted or wrong. put a break point in InitInstance, or any other early called function and trace the problem.
Are you sure the warning is not C4786 ? if it is, then, it might be STL naming demangling ( with all the template stuff )
It's a level 1 warning, and can be left alone; or can be removed with
#pragma warning( disable : 4786 )
before including stl headers.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Diagnostic of the problem is incorrect.
If you run debug version (you do) and you use ASSERT in your code (you do) you will get the wonderful message.
Example:
ASSERT(nValue > 0); //if nValue <= 0 you will see dialog similar to the one you see.
Second item compilation warnings could be safely ignored
|
|
|
|
|
Thanks,
It looks like my assert is failing in the call to
SetRegistryKey?
I don't rememeber writting this part of the code?
How would my code cause this bug?
Thanks
|
|
|
|
|
That code is probably being called by other code which you are invoking. Look at the call stack to see who is calling who.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi,
want to use my own Polygon class called Polygon.
Defined in Polygon.h and Polygon.cpp.
Yet I get compiler errors because Visual C++ keeps
trying to use a pre-defeind Polygon class.
How can I make the compiler use my version of Polygon?
Do I hvae to rename my Polygon.h Polygon.cpp files to
something stupid like My_Polygon.h and My_Polygon.cpp
and change all the instances of Polygon to My_polygon
in those files?
I hope not!
|
|
|
|