|
This is the primary reason why I follow Microsofts recommendation of having Initialization and Termination routines exported from the dll's that are separate from DllMain. Its basically the only way you can guarantee the calling order. Refer: DllMain Callback Function[^]
|
|
|
|
|
Hi,
Thank you for your advice, I have created an exported class object which has an initialise and deinitialise method. They are automatically called by the constructor and destructor for added security. The main application calls the global objects deinitialise method which forces the library to be cleaned upon exit, and before any modules are terminated. This appears to have solved the problem.
Many thanks!
Lea Hayes
|
|
|
|
|
Hi all,
I've create a window using CreateWindowEx windows API and do some work on it. Thats fine. But for the safer operation at the end of all the processing I want to close/destroy the window.
I've try this code, Here m_hwnd_RTFBox is the handle to the window. On the above code there is no compile error, but gives a runtime error and saying there is a unhandled exception on the first line. Where I'm going wrong. I found this from the MSDN, but it wont work.
BOOL clsWin = DestroyWindow(m_hwnd_RTFBox);
if(clsWin != 0)
{
printf("SS");
}
<pre>
I appreciate your help all the time...
Eranga
|
|
|
|
|
I've test another thing also. First send a message to the window and then try to destroy the window. Sending message is ok, but on destroy window gives a error.
BOOL sendMess = PostMessage(m_hwnd_RTFBox, WM_DESTROY, 0, 0);
if(sendMess != 0)
{
DestroyWindow(m_hwnd_RTFBox);
}
Access violation gives on the DestroyWindow() function.
I appreciate your help all the time...
Eranga
|
|
|
|
|
What do you mean it won't work?
Does the exception actually occur on that line?
As for your second post:
Do NOT send WM_DESTROY message to a window. The system does that
for you and also it won't destroy the window.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: What do you mean it won't work?
It's related to the first code which I've put there. When I use DestroyWindow(m_hwnd_RTFBox) , my window is not closed at all.
I appreciate your help all the time...
Eranga
|
|
|
|
|
If DestroyWindow() fails, then call GetLastError()....maybe the
error code will give you a clue to why it's failing.
I would guess the only way it should fail is if the passed HWND is
invalid.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I opened an existing VS 2005 VC++ project by double clicking. I have found lots of header file and .cpp file with native code(unmanaged) as well one Managed form. I am trying to add an extra Form but unable to find a suitable wizard to do it. If I click Project->AddResource, I can select/add dialog box.
Now I am trying to figure it what kind of project it it. How can I know this existing project is a Win32 or CLR or MFC (I don't see any sign of MFC).
Is the any project properties from where I can find the type of project I am working on.
Thank you.
|
|
|
|
|
Did you see WinMain in the project?
|
|
|
|
|
I have started to get, whenever I compile or build, these errors:
>c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C2440: 'initializing' : cannot convert from 'const char [37]' to 'int'
1> There is no context in which this conversion is possible
1>c:\program files\microsoft sdks\windows\v6.0a\include\gdiplusimaging.h(74) : error C2146: syntax error : missing ';' before identifier 'IImageBytes'
1 .............. etc etc
What order should the #include's around '#include <gdiplus.h>' be in?
How can I make my Visual C++ 2008 forget a faulty precompiled header and start again?</gdiplus.h>
|
|
|
|
|
The gdi+ header whould be included after windows.h.
If you're using a typical Visual Studio-produced pre
compiled header, then including the gdi+ header at the end works fine.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I was wondering if the << operator is inherited? I can't get the following to work:
class A
{
public:
A& operator << (double & arg)
{
return *this;
}
};
class B : public A
{
public:
B & operator<<(int & arg)
{
return *this;
}
};
...
B test;
test << 5.0;
with the error that no operator that takes double as argument.
|
|
|
|
|
Hi,
Class 'B' is overloading the operator '<<'. In quick mockup test I managed to get the following to work:
class A<br />
{<br />
public:<br />
A& operator << (double arg)<br />
{<br />
return *this;<br />
}<br />
};<br />
<br />
class B : public A<br />
{<br />
public:<br />
B& operator << (int arg)<br />
{<br />
return *this;<br />
}<br />
<br />
using A::operator <<;
};
I ran into difficulties when using the reference operator '&' for the two arguments.
I hope this is of use!
Lea Hayes
|
|
|
|
|
It appears that when I remove the reference operator, I don't have to specify "using". It's a shame though as I was hoping to subclass an existing implementation and just add a few of my own << operators to write my own types. Looks like I'll have to try defining the operators outside of the class.
|
|
|
|
|
Hi,
Whilst not necessarily the perfect solution, you could inline the operators.
class B : public A<br />
{<br />
...<br />
<br />
public:<br />
inline A& operator << (double & atr)<br />
{<br />
return A::operator << (atr);<br />
}<br />
};
This might be a useful workaround for your scenario.
Lea Hayes
|
|
|
|
|
|
Simon1 wrote: I am programming in c++ and need to ask the user information.
Does somebody has a solution for this problem?
Your question is a bit vague. If you need to prompt the user for information, you can do so regardless of their credentials. If I've misunderstood you, please elaborate.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I am using the ID3LIB and sucsesfuly writing all of the TAG except for the image. I had this working, but I must have messed something up and have spent ages trying to see the bug, but can't. Any help would be much apreciated...
<br />
ID3_Tag myTag("test.mp3");<br />
myTag.Clear();<br />
ID3_Frame* myFrame;<br />
myTag.AddFrame(ID3FID_PICTURE);<br />
myFrame = myTag.Find(ID3FID_PICTURE);<br />
if (NULL != myFrame)<br />
{<br />
ID3_Field* myField;<br />
myField = myFrame->GetField(ID3FN_MIMETYPE);<br />
if (NULL != myField)<br />
{<br />
myField->Set("image/jpeg");<br />
}<br />
myField = myFrame->GetField(ID3FN_PICTURETYPE);<br />
if (NULL != myField)<br />
{<br />
myField->Set(ID3PT_COVERFRONT);<br />
}<br />
myField = myFrame->GetField(ID3FN_DATA);<br />
if (NULL != myField)<br />
{<br />
myField->FromFile("cover.jpg");<br />
}<br />
}<br />
myTag.Update();<br />
An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky
www.mpic3.com - My PIC based MP3 player project
|
|
|
|
|
Hi,
I have the following code, which is adding an OLE object to a word document, linking the OLE file to the document so that the document can be moved to another machine without the linked file, and the linked file can still be seen/activated.
When the code executes on a machine with Office XP, the code functions as desired and the resulting .doc file is ~1.5mb (expected). However, when the code is executed on a machine with Office 2007, the code returns no error, but the resulting file is much smaller (~20kb), and when I double click the OLE object to activate it (having removed the linked object to test it's linked correctly), nothing happens. When I right click on the OLE object and select 'Object', I get a message saying "The object is corrupt or is no longer available". It's as though the LinkToFile = true has been ignored by Word 2007 - is that the case? Or is there a problem with my code?
MicrosoftWord :: _Application lApp;
if (!lApp.CreateDispatch(_T("Word.Application")))
{
AfxMessageBox(_T("sorry old chap, winword's not playing ball"));
return;
}
COleVariant lTrue((short) TRUE);
COleVariant lFalse((short) FALSE);
COleVariant lMissing((long) DISP_E_PARAMNOTFOUND, VT_ERROR);
MicrosoftWord :: Documents lDocsMgr(lApp.GetDocuments());
MicrosoftWord :: _Document lDoc;
lDoc.AttachDispatch(lDocsMgr.Add(lMissing, lFalse));
MicrosoftWord :: Selection lContent(lApp.GetSelection());
CString aFileName = _T("c:\\temp\\my.avi");
MicrosoftWord :: InlineShapes lShapeCollection(lContent.GetInlineShapes());
lShapeCollection.AddOLEObject(lMissing, COleVariant(aFileName), lTrue, lFalse, lMissing, lMissing, lMissing, lMissing);
lDoc.SaveAs(COleVariant(_T("c:\\temp\\abc.doc")), lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing);
lDoc.Close(lMissing, lMissing, lMissing);
lApp.Quit(lMissing, lMissing, lMissing);
Many thanks,
- Dylan
- Dy
|
|
|
|
|
prerequiste information:
VC++ windows application (Dialog based)
On dialog, List control is added. I have embedded edit control in List control.
A Cancel button on dialog.
Problem:
When cursor (focus) is on edit control (that is in list control), if i click Cancel button, the event is not handled unless i click it again. I mean, i need to click Cancel button again to cancel the dialog.
In code, When i click Cancel button, only (user defined) OnLostFocus() function of edit control is called.
|
|
|
|
|
With thanks to earlier help, I now know how to read and write JPG and GIF and some other graphics files; there is an example on http://msdn2.microsoft.com/en-us/library/ms533844.aspx .
But, behind the class function calls Image:Image(WCHAR* filename) and Image:Save(WCHAR*filename,...), please what are the names of the basic bottom-level Windows functions that read and write graphics files without going though classes?
|
|
|
|
|
There isn't Win32 API to do that stuff.
You have to use either GDI+ (hence classes) or third party (free?) libraries.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Does Visual C++ 2008 (either the free download or the paid-for version) have an option to run in the old form with the Windows functions expecting old-type 8-bit character arrays?
For example, I get the impression that the old MessageBox() function with char* arguments, may still exist, but that there is also a new library routine MessageBoxW() with WCHAR* arguments, and then #define MessageBox MessageBoxW somewhere in the library blocks access to the old MessageBox() function; and similarly with many other Windows functions.
I know that this is to handle 16-bit Unicode characters; but my current program is a graphics program, and I am not interested in handling Devanagari or Arabic or Chinese etc characters and I am content with the old ascii set; and going through a biggish program adapting for so many Windows function calls being masked by new forms which need WCHAR* instead of char* arguments, is getting to be a total nightmare, and the more I have to change, the more risk is of mistakes getting in.
|
|
|
|
|
In VS2005 and up, projects default to Unicode. Change the project setting for Character Set to Not Set (this is what they're called in 2005) and you'll be back to ANSI.
Judy
|
|
|
|
|
Thanks. In Visual C++ 2008 mouse the menu Project -> (prog_name) Property Pages -> Configuration Properties -> General, and Character Set is 3rd from the bottom in the list of properties inside the box.
|
|
|
|