Click here to Skip to main content
15,929,025 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSaving file with MCI Pin
3-Oct-01 9:16
suss3-Oct-01 9:16 
QuestionHow do I get a process' opened files names Pin
Le centriste3-Oct-01 9:03
Le centriste3-Oct-01 9:03 
GeneralProblem with CDaoRecordset "Too few parameters. Expected 1" Pin
Cheickna3-Oct-01 8:21
Cheickna3-Oct-01 8:21 
GeneralRe: Problem with CDaoRecordset "Too few parameters. Expected 1" Pin
Carlos Antollini3-Oct-01 8:35
Carlos Antollini3-Oct-01 8:35 
QuestionHow to check a FTP connection's validation? Pin
Chaos Lawful3-Oct-01 6:46
Chaos Lawful3-Oct-01 6:46 
AnswerRe: How to check a FTP connection's validation? Pin
Carlos Antollini3-Oct-01 8:37
Carlos Antollini3-Oct-01 8:37 
GeneralAfxbeginThread Pin
meirav3-Oct-01 6:44
meirav3-Oct-01 6:44 
GeneralRe: AfxbeginThread Pin
Chaos Lawful3-Oct-01 6:56
Chaos Lawful3-Oct-01 6:56 
You should not pass dialog pointer to the thread because it may be invalid. I think you can use GetSafeHwnd() to get the handle of the main dialog and pass it to the thread. In the thread you can use FromHandle() to get back the main dialog pointer and then you can access the main dialog class.
Here is an example:

UINT ThreadProc(LPVOID);// the thread proc

HWND hWnd; // for handle of main dialog

BOOL C???Dlg::OnInitDialog()
{
...// some codes
hWnd=GetSafeHwnd();
...// other codes
}

void C???Dlg::OnButton1() // Button1 is a sample button
{
AfxBeginThread(ThreadProc,NULL);
}

UINT ThreadProc(LPVOID lpData)
{
C???Dlg *pDlg=(C???Dlg*)C???Dlg::FromHandle(hWnd); // get the main dlg pointer
...// do what you want to do
}

You can also pass the handle through the thread proc's lpData pointer, then you don't have to declare the hWnd as a external variable.Smile | :)

Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
GeneralRe: AfxbeginThread Pin
meirav3-Oct-01 19:53
meirav3-Oct-01 19:53 
GeneralRe: AfxbeginThread Pin
Chaos Lawful3-Oct-01 19:56
Chaos Lawful3-Oct-01 19:56 
GeneralRe: AfxbeginThread Pin
meirav3-Oct-01 19:59
meirav3-Oct-01 19:59 
GeneralRe: AfxbeginThread Pin
Chaos Lawful3-Oct-01 22:21
Chaos Lawful3-Oct-01 22:21 
QuestionMSComm CByteArray to BStr, how do I? Pin
3-Oct-01 5:14
suss3-Oct-01 5:14 
GeneralNET DataSet Implemented in Visual C++ Pin
jawillia993-Oct-01 4:34
jawillia993-Oct-01 4:34 
GeneralGrids Pin
3-Oct-01 4:23
suss3-Oct-01 4:23 
GeneralRe: Grids Pin
Tomasz Sowinski3-Oct-01 4:37
Tomasz Sowinski3-Oct-01 4:37 
GeneralRe: Grids Pin
3-Oct-01 4:41
suss3-Oct-01 4:41 
GeneralRe: Grids Pin
NormDroid3-Oct-01 4:46
professionalNormDroid3-Oct-01 4:46 
Generalwarning C4786: Pin
zack3-Oct-01 3:10
zack3-Oct-01 3:10 
GeneralRe: warning C4786: Pin
Tomasz Sowinski3-Oct-01 4:40
Tomasz Sowinski3-Oct-01 4:40 
GeneralRe: warning C4786: Pin
zack3-Oct-01 4:57
zack3-Oct-01 4:57 
GeneralRe: warning C4786: Pin
John M. Drescher11-Oct-01 5:35
John M. Drescher11-Oct-01 5:35 
GeneralAccessing Data Islands from a COM component on a HTML page Pin
Michael A Barnhart3-Oct-01 3:08
Michael A Barnhart3-Oct-01 3:08 
GeneralRAS Dial Pin
Firoz3-Oct-01 2:38
Firoz3-Oct-01 2:38 
GeneralCEdit Pin
3-Oct-01 1:40
suss3-Oct-01 1:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.