Setting Text of Edit Control in Dialog Box of Control Panel Applet 
Author Message
 Setting Text of Edit Control in Dialog Box of Control Panel Applet

I've written a Control Panel Applet including just one dialog box. The
dialog box class has been derived from CDialog and there are several
controls on it, one of which is a edit control. I want to set the text of
this control. So I've done something like:

CWnd* intervalLengthLabel;
intervalLengthLabel = GetDlgItem(IDC_INTERVAL_LENGTH);
if (intervalLengthLabel != NULL)
{  //OK
    intervalLengthLabel->SetWindowText("just some text");

Quote:
}

else
{  //error
    AfxMessageBox("Not been able to get EditBox handle");

Quote:
}

Well, I've used this on several other projects (dialog based applications),
no prob. But on this project, it just doesn't return the handle. The error
doesn't fall under the category 'misspelled'. I also tried to use it that
way GetDlgItem(IDC_INTERVAL_LENGTH, intervalLengthLabel); - well, it didn't
work either. The compiler actually didn't know this function though it is in
the MSDN documentation. I don't see any difference between the two projects
(besides one is a dialog based application and the other is a dll used as
cpl) so I don't know what's going wrong... Any suggestions? Thanks for any
help

cheers, thomas

----------------------------------------------------------------------
my eMail address has been modified
I think you can guess what should be removed...



Fri, 09 Mar 2001 03:00:00 GMT  
 Setting Text of Edit Control in Dialog Box of Control Panel Applet
I am not clear where you called GetDlgItem() in your real project. Its
return
value (CWnd*) can not be stored for future use. Just in case you did
this way.

Daxin

Quote:

> I've written a Control Panel Applet including just one dialog box. The

> dialog box class has been derived from CDialog and there are several
> controls on it, one of which is a edit control. I want to set the text
> of
> this control. So I've done something like:

> CWnd* intervalLengthLabel;
> intervalLengthLabel = GetDlgItem(IDC_INTERVAL_LENGTH);
> if (intervalLengthLabel != NULL)
> {  //OK
>     intervalLengthLabel->SetWindowText("just some text");
> }
> else
> {  //error
>     AfxMessageBox("Not been able to get EditBox handle");
> }

> Well, I've used this on several other projects (dialog based
> applications),
> no prob. But on this project, it just doesn't return the handle. The
> error
> doesn't fall under the category 'misspelled'. I also tried to use it
> that
> way GetDlgItem(IDC_INTERVAL_LENGTH, intervalLengthLabel); - well, it
> didn't
> work either. The compiler actually didn't know this function though it
> is in
> the MSDN documentation. I don't see any difference between the two
> projects
> (besides one is a dialog based application and the other is a dll used
> as
> cpl) so I don't know what's going wrong... Any suggestions? Thanks for
> any
> help

> cheers, thomas

> ----------------------------------------------------------------------

> my eMail address has been modified
> I think you can guess what should be removed...



Fri, 09 Mar 2001 03:00:00 GMT  
 Setting Text of Edit Control in Dialog Box of Control Panel Applet
Maybe define a membervariable. Then, you doesnt have to use GetDlgItem()

Thomas Jachmann schrieb in Nachricht ...

Quote:
>I've written a Control Panel Applet including just one dialog box. The
>dialog box class has been derived from CDialog and there are several
>controls on it, one of which is a edit control. I want to set the text of
>this control. So I've done something like:

>CWnd* intervalLengthLabel;
>intervalLengthLabel = GetDlgItem(IDC_INTERVAL_LENGTH);
>if (intervalLengthLabel != NULL)
>{  //OK
>    intervalLengthLabel->SetWindowText("just some text");
>}
>else
>{  //error
>    AfxMessageBox("Not been able to get EditBox handle");
>}

>Well, I've used this on several other projects (dialog based applications),
>no prob. But on this project, it just doesn't return the handle. The error
>doesn't fall under the category 'misspelled'. I also tried to use it that
>way GetDlgItem(IDC_INTERVAL_LENGTH, intervalLengthLabel); - well, it didn't
>work either. The compiler actually didn't know this function though it is
in
>the MSDN documentation. I don't see any difference between the two projects
>(besides one is a dialog based application and the other is a dll used as
>cpl) so I don't know what's going wrong... Any suggestions? Thanks for any
>help

>cheers, thomas

>----------------------------------------------------------------------
>my eMail address has been modified
>I think you can guess what should be removed...



Fri, 09 Mar 2001 03:00:00 GMT  
 Setting Text of Edit Control in Dialog Box of Control Panel Applet
I've never done it in a control panel application, but in a normal DLL you
have to deal with the resource handle of the application, because the
calling application has its own resources. Try something like
AFX_MANAGE_STATE or AfxSetResourceHandle.

--
Dirk Bohnemeyer
p.s. For e-mail remove one of the 'o's from my address.
-------------------------------------------------------
Thomas Jachmann schrieb in Nachricht ...

Quote:
>I've written a Control Panel Applet including just one dialog box. The
>dialog box class has been derived from CDialog and there are several
>controls on it, one of which is a edit control. I want to set the text of
>this control. So I've done something like:

>CWnd* intervalLengthLabel;
>intervalLengthLabel = GetDlgItem(IDC_INTERVAL_LENGTH);
>if (intervalLengthLabel != NULL)
>{  //OK
>    intervalLengthLabel->SetWindowText("just some text");
>}
>else
>{  //error
>    AfxMessageBox("Not been able to get EditBox handle");
>}

>Well, I've used this on several other projects (dialog based applications),
>no prob. But on this project, it just doesn't return the handle. The error
>doesn't fall under the category 'misspelled'. I also tried to use it that
>way GetDlgItem(IDC_INTERVAL_LENGTH, intervalLengthLabel); - well, it didn't
>work either. The compiler actually didn't know this function though it is
in
>the MSDN documentation. I don't see any difference between the two projects
>(besides one is a dialog based application and the other is a dll used as
>cpl) so I don't know what's going wrong... Any suggestions? Thanks for any
>help

>cheers, thomas

>----------------------------------------------------------------------
>my eMail address has been modified
>I think you can guess what should be removed...



Sat, 10 Mar 2001 03:00:00 GMT  
 Setting Text of Edit Control in Dialog Box of Control Panel Applet
I finally made it.
The problem was just that I called GetDlgItem right after the construction
of the dialog box' class. Ask god why but at this stage, the controls within
the associated dialog box weren't known.
I then tried to call GetDlgItem from within OnInitDialog (overridden
function from CWnd) and stored the return value in a member variable (CWnd*)
of the dialog class - though you actually shouldn't store those pointers, it
worked for me ... any comments on that? I then could use this pointer from
anywhere, eg OnHScroll (in which I needed this reference to the edit field).

thanks for your help
cheers, thomas

----------------------------------------------------------------------
my eMail address has been modified
I think you can guess what should be removed...



Sat, 10 Mar 2001 03:00:00 GMT  
 Setting Text of Edit Control in Dialog Box of Control Panel Applet
The CWnd you got in OnInitDialog by calling GetDlgItem can be stored when a
couple steps are taken.  First that CWnd will exist as long as the HWND
under it is still a window, thus until the dialog is opened or until you
delete the CWnd pointer you got (which you won't do ...).  MFC uses a CMap
to map its MFC objects to WIN32 handles, when you delete an MFC object it is
flagged for deletion that will be done in the next OnIdle loop.

--
Patrice LaRoche, ing. stag., mcp
Cybectec inc.

WWW: www.cybectec.com
Phone: (418) 832-0097, ext 22
Fax: (418) 832-5582

Quote:

>I finally made it.
>The problem was just that I called GetDlgItem right after the construction
>of the dialog box' class. Ask god why but at this stage, the controls
within
>the associated dialog box weren't known.
>I then tried to call GetDlgItem from within OnInitDialog (overridden
>function from CWnd) and stored the return value in a member variable
(CWnd*)
>of the dialog class - though you actually shouldn't store those pointers,
it
>worked for me ... any comments on that? I then could use this pointer from
>anywhere, eg OnHScroll (in which I needed this reference to the edit

field).


Sat, 10 Mar 2001 03:00:00 GMT  
 Setting Text of Edit Control in Dialog Box of Control Panel Applet



Quote:
> I finally made it.
> The problem was just that I called GetDlgItem right after the construction
> of the dialog box' class. Ask god why but at this stage, the controls within
> the associated dialog box weren't known.
> I then tried to call GetDlgItem from within OnInitDialog (overridden
> function from CWnd) and stored the return value in a member variable (CWnd*)
> of the dialog class - though you actually shouldn't store those pointers, it
> worked for me ... any comments on that? I then could use this pointer from
> anywhere, eg OnHScroll (in which I needed this reference to the edit field).

Why don't you call GetDlgItem in the function where you need the pointer (eg.
OnHScroll)?
This should work fine and you don't store a pointer which may be invalid.

Harald



Sat, 10 Mar 2001 03:00:00 GMT  
 Setting Text of Edit Control in Dialog Box of Control Panel Applet
It is normal, that no dialog item is available after construction. The items
will be created during the create process, and this takes place by calling
Create() or DoModal().

--
Dirk Bohnemeyer
p.s. For e-mail remove one of the 'o's from my address.
-------------------------------------------------------
Thomas Jachmann schrieb in Nachricht ...

Quote:
>I finally made it.
>The problem was just that I called GetDlgItem right after the construction
>of the dialog box' class. Ask god why but at this stage, the controls
within
>the associated dialog box weren't known.
>I then tried to call GetDlgItem from within OnInitDialog (overridden
>function from CWnd) and stored the return value in a member variable
(CWnd*)
>of the dialog class - though you actually shouldn't store those pointers,
it
>worked for me ... any comments on that? I then could use this pointer from
>anywhere, eg OnHScroll (in which I needed this reference to the edit
field).

>thanks for your help
>cheers, thomas

>----------------------------------------------------------------------
>my eMail address has been modified
>I think you can guess what should be removed...



Sun, 11 Mar 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. how to set focus to control panel applet if instance already exists

2. how to set focus to control panel applet if instance already exists

3. Dialog Handles and accessing Control Panel Applets?

4. How do I set focus to Edit Box control in Dialog app

5. Simple: Control Panel Applet with C#?

6. How to debug control panel applet?

7. debugging a control panel applet?

8. Debugging Control Panel Applets

9. Control Panel Applet & DialogBox

10. How to lanuch control panel applets?

11. SendMessage vs. Control Panel Applet

12. Odd Control Panel Applet failures

 

 
Powered by phpBB® Forum Software