|
Hi,
I am writing a DLL that links dynamically to MFC. I am having a serious problem with threads; when I create a thread using AfxBeginThread, the thread process fails.
After examining with the debugger, it seems that the data I pass to the thread (a void*, which in my case is a pointer to a CObject* derived class) is being corrupted; calling ASSERT_KINDOF on the object fails (the actual failure is that internally the object cannot call GetRuntimeClass) and skipping ASSERT_KINDOF and simply calling a function of the class fails.
It seems the object's virtual function table is being problematic. At the beginning of every possible relevant function I have used AFX_MANAGE_STATE(AfxGetStaticModuleState()); to see if this helps. It doesn't.
Is there an in-built limitation to threading like this in DLLs? BTW this is not an MFC extension DLL, just a dll that dynamically links to MFC.
I have a big deadline approaching and any help would be enormously appreciated!
Thanks in advance!
Dave Kerr
|
|
|
|
|
|
CreateThread gives exactly the same problem. I am convinced it is a memory issue. The first part of the thread process is:
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// Cast the data.
CThreadFunction* pFunction = reinterpret_cast<cthreadfunction*>(pData);
// Assert it is the correct type.
ASSERT_KINDOF(CThreadFunction, pFunction);
// Do the work.
UINT uError = pFunction->DoFunction();
...
However when I examine pFunction in the memory window, the memory looks to be " .Anywhere.dll _AFX_MANAGE_STATE.." so the pointer is definately not pointing to the correct address.
Any ideas?
Dave Kerr
codechamber@hotmail.com
http://www.codechamber.com
|
|
|
|
|
hi all
plz tell me how can i place a picture
(image ) on buton control in
mfc dialog bsed application
plz send some example
Ashish Dogra
MCA
Noida
|
|
|
|
|
|
TO put an image on the button instead of making the variable of CButton type create it as CBitmapButton and use LoadBitmap to set the image on the button.;
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
like this
CButton m_BitmapButton;
m_BitmapButton.Create("Test",BS_BITMAP|WS_CHILD|WS_VISIBLE,CRect(0,40,150,63),this,1);
m_BitmapButton.SetBitmap((HBITMAP)LoadImage(NULL,"c:\\0.bmp",IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION));
whitesky
|
|
|
|
|
ok sir but i declare this code in OnInitDialog() function
now it does not show any picture
and plz tell me my picture is .jpg so plz tellme where this code is declared
and how to show that picture
plz...............sir
Please mail me
|
|
|
|
|
I am afraid the LoadImage function from the pervious sample cannot work with JPEG file and accept BMP files only. Therefore you should check the code using some BMP file.
If it works, you have to convert your image to BMP format. For this purpose I think you can use Save As command of the Paint system accessory. Or see if Visual Studio can be used for this.
|
|
|
|
|
one way <CImage class>
whitesky
|
|
|
|
|
You dont need to create i created for this that i show this code
if you have one button set bitmap in property form button in property window or use
m_Button.ModifyStyle(0,BS_BITMAP);
(Jpg)->not problem use CImage class
and see
<br />
m_BitmapButton.Create(_T("Test"),BS_BITMAP|WS_CHILD|WS_VISIBLE,CRect(0,40,150,63),this,1);<br />
CImage m_Image;<br />
m_Image.Load(_T("e:\\0.jpg"));<br />
m_BitmapButton.SetBitmap(m_Image.Detach());<br />
//include AtlImage.h
whitesky
|
|
|
|
|
See here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Are you trying to browse for a file?
for that purpose use CFileDialog
CFileDialog d(true);
d.DoModal();
CString strPath = d.GetPathName();
SaRath.
"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."
My Blog | Understanding State Pattern in C++
|
|
|
|
|
no, what i want is i have filename and i want the path of the file name.
so that i can use this path .
ram
|
|
|
|
|
What problem are you facing using the GetFullPathName() as I suggest in my post?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
How to get this file?
whitesky
|
|
|
|
|
i have file name and i want to do get the path of the file name.so that i can play a song
ram.
|
|
|
|
|
You have a filename ok.(Test.mp3) but when you run your program how to get this file?if you can read this you can get path unless you want to save this file in your program
whitesky
|
|
|
|
|
if u want to read a file we must have a path.without knowing the path how we can read.
|
|
|
|
|
very well my friend you said path well when you have a path use from this
path for file and save this path ok (your message how to get path a file)
whitesky
|
|
|
|
|
If you have the name of the file use
GetFullPathName()
See Here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 7:07 Friday 30th June, 2006
|
|
|
|
|
i used getFullPath().it is giving me the second folder path
actully my problem is i have project on Mp3PLayer.
if i add folder to the listbox all the files in the folder and if u click on thew song it wil get the path and it will work.if i add second folder to the listbox then if we click on first folder file it willnot play.
because they also taking the path of second folder.
pplase help.
ram.
-- modified at 7:51 Friday 30th June, 2006
|
|
|
|
|
You can use either PathRemoveFileSpec() or _splitpath() .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thank u for ur response.
how we can without path how we can split path.
|
|
|
|