Click here to Skip to main content
15,905,612 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralTrouble with GetLogicalDrives() function Pin
Dev5786-Mar-04 13:28
Dev5786-Mar-04 13:28 
GeneralRe: Trouble with GetLogicalDrives() function Pin
Curi0us_George6-Mar-04 13:44
Curi0us_George6-Mar-04 13:44 
GeneralP.S. Pin
Curi0us_George6-Mar-04 13:49
Curi0us_George6-Mar-04 13:49 
GeneralRe: Trouble with GetLogicalDrives() function Pin
P-Rex7-Mar-04 21:45
P-Rex7-Mar-04 21:45 
GeneralCould some please post a working example Pin
MeterMan6-Mar-04 12:40
MeterMan6-Mar-04 12:40 
GeneralRe: Could some please post a working example Pin
Curi0us_George6-Mar-04 13:10
Curi0us_George6-Mar-04 13:10 
GeneralRe: Could some please post a working example Pin
MeterMan6-Mar-04 14:04
MeterMan6-Mar-04 14:04 
GeneralRe: Could some please post a working example Pin
Curi0us_George7-Mar-04 12:02
Curi0us_George7-Mar-04 12:02 
Ok, I'm trying to understand some of what's going on. (I'm not a fan of mfc because it's so convoluted.)

lines 267 and 268:
CCash3mfcDlg *pdlg;
*pdlg = (CCash3mfcDlg*)CWnd::FromHandle("handle");

You definitely can't do that. First off, FromHandle is expecting an HWND, not a char *. It shouldn't even compile. Second, you're dereferencing the pointer (pdlg) and assigning a different pointer to the object pdlg points to. It's difficult to explain what that code says, because it's not valid. But looking through the rest of the function, I can't see anywhere you are using pdlg, so just remove those two lines completely. They've got several problems, and they aren't necessary for any other code.



Here's your THREADSTRUCT definition:
typedef struct THREADSTRUCT
{
CCash3mfcDlg* _this;
}THREADSTRUCT;

(You could simplify that by dropping the "typedef" and replacing the trailing "THREADSTRUCT;" with just ";". Your definition is redundant. But I don't think you should have any trouble with it.)

However, int line 254, you're setting the _this variable to an HWND value:
_param->_this = GetSafeHwnd();

That's also not allowed. An HWND and an object pointer are completely separate, relatively unrelated entities.



I'd suggest that you simplify the whole thing. Recreate your project from scratch, and only add in the bare minimum of functionality, and find the first point at which it fails. Right now, you've got a pretty big chunk of code, and that makes it harder to step through and figure out the point (or points) where you've got problems.

I'd also suggest that you change StartThread and
Ongobutton as follows:
UINT CCash3mfcDlg::StartThread(LPVOID param)
{
HWND wnd = (HWND)param;
CCash3mfcDlg * dlg = (CCash3mfcDlg*)CWnd::FromHandle(wnd);
dlg->run();
return 1;
}

void CCash3mfcDlg::Ongobutton()
{
AfxBeginThread (StartThread,GetSafeHwnd());
UpdateData(TRUE); // I actually don't know what this does, but no matter.
}

I believe that should do what you want.
GeneralRe: Could some please post a working example Pin
MeterMan7-Mar-04 16:12
MeterMan7-Mar-04 16:12 
GeneralRe: Could some please post a working example Pin
DougW486-Mar-04 22:44
DougW486-Mar-04 22:44 
GeneralRe: Could some please post a working example Pin
MeterMan7-Mar-04 5:28
MeterMan7-Mar-04 5:28 
GeneralRe: Could some please post a working example Pin
DougW487-Mar-04 5:53
DougW487-Mar-04 5:53 
GeneralRe: Could some please post a working example Pin
MeterMan7-Mar-04 6:09
MeterMan7-Mar-04 6:09 
GeneralRe: Could some please post a working example Pin
DougW487-Mar-04 6:52
DougW487-Mar-04 6:52 
Generaltoolbar like internet explorer Pin
asher_ungar6-Mar-04 12:32
asher_ungar6-Mar-04 12:32 
GeneralEdit Box data input and output hexadecimal formatted data Pin
Freddie Code6-Mar-04 8:45
Freddie Code6-Mar-04 8:45 
GeneralChange exe file in project Pin
Mazdak6-Mar-04 6:20
Mazdak6-Mar-04 6:20 
GeneralRe: Change exe file in project Pin
Prakash Nadar6-Mar-04 6:31
Prakash Nadar6-Mar-04 6:31 
GeneralRe: Change exe file in project Pin
Mazdak6-Mar-04 7:30
Mazdak6-Mar-04 7:30 
GeneralRe: Change exe file in project Pin
Joe Woodbury6-Mar-04 11:45
professionalJoe Woodbury6-Mar-04 11:45 
GeneralRe: Change exe file in project Pin
Mazdak6-Mar-04 20:00
Mazdak6-Mar-04 20:00 
Generalminimize to system tray Pin
Otty6-Mar-04 6:02
Otty6-Mar-04 6:02 
GeneralRe: minimize to system tray Pin
tn_dang22-Apr-04 3:21
tn_dang22-Apr-04 3:21 
GeneralHelp I can't figure out how to update my edit box in visual c++ mfc Pin
MeterMan6-Mar-04 5:59
MeterMan6-Mar-04 5:59 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
Michael Dunn6-Mar-04 6:04
sitebuilderMichael Dunn6-Mar-04 6:04 

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.