Click here to Skip to main content
16,007,472 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: testing for <esc> key Pin
jmkhael28-Apr-04 0:27
jmkhael28-Apr-04 0:27 
GeneralRe: testing for <esc> key Pin
Anonymous28-Apr-04 3:25
Anonymous28-Apr-04 3:25 
GeneralMSDN 2003, to Visual C++ 6 Pin
Dassatar27-Apr-04 11:21
Dassatar27-Apr-04 11:21 
GeneralRe: MSDN 2003, to Visual C++ 6 Pin
Garth J Lancaster27-Apr-04 11:38
professionalGarth J Lancaster27-Apr-04 11:38 
GeneralRe: MSDN 2003, to Visual C++ 6 Pin
Roger Wright27-Apr-04 12:49
professionalRoger Wright27-Apr-04 12:49 
GeneralRe: MSDN 2003, to Visual C++ 6 Pin
Prakash Nadar27-Apr-04 18:23
Prakash Nadar27-Apr-04 18:23 
QuestionSetDlgItemText from different thread ? Pin
rmnowick27-Apr-04 11:01
rmnowick27-Apr-04 11:01 
AnswerRe: SetDlgItemText from different thread ? Pin
rmnowick27-Apr-04 11:56
rmnowick27-Apr-04 11:56 
I have some additional information. When running the code in debug I found that the value of hdlg in the code above was zero. That explains why the SetDlgItemText was not working. This presumably comes from my main dialog window code. The routine above has an

extern HWND hdlg;

so as to specify that the hdlg is declared in a different file. When looking through my dialog routine the interesting thing is that there does not appear to be anywhere that the variable hdlg gets set!

Here is the code that creates the dialog box in question that doesn't return until the dialog box goes away...

return DialogBox(hInstance, // was (HINSTANCE)hInstance<br />
                MAKEINTRESOURCE(IDD_DIALOG1), <br />
                NULL,<br />
                (DLGPROC) DialogProc); <br />


When you look into DialogProc you see the following...

BOOL CALLBACK DialogProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
<br />
	// Only save the first DBG_SIZE received serial message notifications<br />
	if (t_win_msgs < DBG_SIZE)<br />
	{<br />
		GetTimeStampStr(ats, char_ts, char_ts2);<br />
		strcpy(win_msg_time[t_win_msgs],char_ts2);<br />
		win_msg[t_win_msgs] = uMsg;<br />
		strcpy(win_msg_text[t_win_msgs],"");<br />
		if (uMsg == WM_COMMAND)<br />
			strcpy(win_msg_text[t_win_msgs],"WM_COMMAND");<br />
		if (uMsg == WM_TIMER)<br />
			strcpy(win_msg_text[t_win_msgs],"WM_TIMER");<br />
		if (uMsg == WM_AGILENT)<br />
			strcpy(win_msg_text[t_win_msgs],"ser agi");<br />
		win_hi_wp[t_win_msgs] = HIWORD(wParam);<br />
		win_lo_wp[t_win_msgs] = LOWORD(wParam);<br />
		t_win_msgs++;	// Total messages<br />
	}<br />
<br />
	switch (uMsg)<br />
	{<br />
<br />
	case WM_AGILENT:<br />
		return 1;<br />
<br />
	case WM_INITDIALOG: 	//----------------------------INITDIALOG<br />
		<br />
		InitDialogProc(hdlg, uMsg, wParam, lParam);<br />
		return 1;<br />
<br />
	// Serial data processing if done periodically<br />
	case WM_TIMER:<br />
<br />
		SetDlgItemText(hdlg,IDC_STATIC_1,(LPCSTR)static_message_101);<br />
		SetDlgItemText(hdlg,IDC_STATIC_2,(LPCSTR)static_message_106);<br />
		return 1;<br />


The hwnd variable is the first parameter passed into DialogProc. It is then passed as the first parameter to InitDialogProc. It is used in there to do a bunch of stuff including naming the window title, etc...

But as I mentioned it does not appear to actually get set anywhere that I can see, unless it is somehow done automatically? If so, then why can't I see it in the other thread?

The description of the DialogProc routine seems to show that the first parameter (hdlg) is passed in. In my code, this is not getting set prior to the call to DialogBox that has DialogProc as the 4th parameter. When I set a break in DialogProc on the first line and then check hdlg, it has a non-zero value. When did that get set?

I should mention that the calls to SetDlgItemText under WM_TIMER are the ones that are working. I would just prefer to have the other thread set them directly instead of having to poll them in this manner form the main dialog box.

Robert
GeneralRe: SetDlgItemText from different thread ? Pin
rmnowick27-Apr-04 12:42
rmnowick27-Apr-04 12:42 
QuestionHow to get Table Names while using ADO Pin
Chauhan Chirag27-Apr-04 10:30
Chauhan Chirag27-Apr-04 10:30 
AnswerRe: How to get Table Names while using ADO Pin
John M. Drescher27-Apr-04 10:49
John M. Drescher27-Apr-04 10:49 
GeneralRe: How to get Table Names while using ADO Pin
Chauhan Chirag27-Apr-04 10:57
Chauhan Chirag27-Apr-04 10:57 
GeneralRe: How to get Table Names while using ADO Pin
John M. Drescher27-Apr-04 16:36
John M. Drescher27-Apr-04 16:36 
GeneralAccessing public variables Pin
Krugger40427-Apr-04 10:25
Krugger40427-Apr-04 10:25 
GeneralRe: Accessing public variables Pin
Joaquín M López Muñoz27-Apr-04 10:46
Joaquín M López Muñoz27-Apr-04 10:46 
GeneralRe: Accessing public variables Pin
Ravi Bhavnani27-Apr-04 11:14
professionalRavi Bhavnani27-Apr-04 11:14 
GeneralWindows Style Pin
Anthony988727-Apr-04 8:30
Anthony988727-Apr-04 8:30 
GeneralRe: Windows Style Pin
David Crow27-Apr-04 8:55
David Crow27-Apr-04 8:55 
Generalchar* shows up as sbyte* Pin
schoolGirl27-Apr-04 8:27
schoolGirl27-Apr-04 8:27 
GeneralRe: char* shows up as sbyte* Pin
Antti Keskinen27-Apr-04 11:04
Antti Keskinen27-Apr-04 11:04 
QuestionCTabCtrl with CFormView? Pin
emanuelllle1227-Apr-04 7:21
emanuelllle1227-Apr-04 7:21 
AnswerRe: CTabCtrl with CFormView? Pin
toxcct27-Apr-04 8:45
toxcct27-Apr-04 8:45 
QuestionMenu with Icons? Pin
blue-marie27-Apr-04 7:03
blue-marie27-Apr-04 7:03 
AnswerRe: Menu with Icons? Pin
toxcct27-Apr-04 7:12
toxcct27-Apr-04 7:12 
GeneralRe: Menu with Icons? Pin
blue-marie27-Apr-04 7:33
blue-marie27-Apr-04 7:33 

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.