Solved

WM_NEXTDLGCTL to hi-lite edit control

Posted on 1998-01-16
9
1,356 Views
Last Modified: 2013-12-26
I am trying to highlite an edit control when the user first enters the dialog box to indicate that a field must be filled in. I have tried many many ways to accomplish this but none successful. Last input I got from here was to use WM_NEXTDLGCTL. WM_NEXTDLGCTL states that, unlike SETFOCUS, it modifies the border around the control. It also says to use PostMessage. I assume that this means that the background is microsoft blue and the text is white.

Well this is what I am doing;  //some of this is psuedo code

RESPONSE_TABLE
  EV_WM_NEXTDLGCTL
END
Constructor {
 pCustName = new TEdit(this, IDC_IN_NAME);
 // other controls instantiated
}

void Dialog::SetupWindow{
   TDialog::SetupWindow();
   PostMessage(WM_NEXTCLGCTL, ID_IN_NAME, 1);
};

void Dialog::EvNextDlgtCtl(UINT, hctOrDir, UINT isHctl){
   pCustName->SetText("Enter Name");
};

The dialog displays with the text Enter Name without the text being highlited. What am I doing wrong? Also, what are the parameters to EvNextDlgCtl??
0
Comment
Question by:dutch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 

Author Comment

by:dutch
ID: 1299545
Adjusted points to 200
0
 

Author Comment

by:dutch
ID: 1299546
No Takers????
0
 
LVL 3

Accepted Solution

by:
JPM earned 250 total points
ID: 1299547
HI!

There is a simple way to do the job :

- declare a TEdit* xxx  member in your dialog derived class

- in the constructor of that class, you have to put :
       xxx = new TEdit(..........);

- in SetupWindow of the dialog class
        ......
        xxx->SetFocus();
- in destructor :   delete xxx;

et voilà !

I usually do this for all my forms ( for example an edit field has been reserved for storing keys )

Hope this helps.
Jean-Paul
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dutch
ID: 1299548
Sorry, but it didn't work. First, to make sure everyone understands the question, I want the text "Enter Customer Name" highlited (blue background, white letters) when the dialog is instantiated. This is like what happens to your userid if you enter the wrong password logging in to this site.

the code is as follows;
in header file

   protected:  
      TEdit* pCustName;

in CPP file

CustDialog::CustDialog(TWindow* Parent)           //constructor
                      :TDialog(Parent, IDD_CUST_DIALOG){  
   SetCaption("Customer Data");
   pCustName = new TEdit(this, IDC_IN_NAME);
};

void CustDialog::SetupWindow{
   TDialog::SetupWindow();
   pCustName->SetText("Enter Customer Name");
   pCustName->SetFocus();
   // i have tried with either one being first - no difference
};

CustDialog::~CustDialog{
   delete pCustName;
};

The dialog comes up with the TStatic control Customer Name and the TEdit control next to it with the text "Enter Customer Name". However it is not highlited - the text is in black and the background is white. Everything else does work. I can get the text and file for later use.

0
 
LVL 3

Expert Comment

by:JPM
ID: 1299549
That's strange!

In my program, I almost wrote the same code as yours ( SetDlgItemText instead of SetText ) to get the name of a project
and it works!
It sounds like something has been overwritten!

What about  EV_WM_SETFOCUS, EV_WM_KILLFOCUS ?





0
 
LVL 3

Expert Comment

by:JPM
ID: 1299550
If you wish, ask the supervisor for my E-mai! address and I 'll send you an Edit derived class ( with effects ) so you could try it.
Bye
        Jean-paul

0
 

Author Comment

by:dutch
ID: 1299551
Jean-Paul, I did not try to set/kill focus by placing a WM_SETFOCUS message on the queue (I assume you mean using the PostMessage function). I will be on a business trip until this weekend and wil not have the time to test this out. If I figure out how to send a note to the adminstrator to get you id while I am in this session, I will do that. Thanks...
0
 
LVL 3

Expert Comment

by:JPM
ID: 1299552
To get my ig:
 get to the Expert-Exchange 's main window
 toggle FAQ
 #14 How to contact....
Send a message

I have tried it this way!

 
0
 

Author Comment

by:dutch
ID: 1299553
Thanks...
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question