|
Is this a C / C++ / MFC question?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
How to organize nested props in VueJS?
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thank you very much
|
|
|
|
|
I've used SendMessageW API to direct an EM_SETSEL message to
a designated Edit control to make it locates the searched text
entered from the another Edit control. Why it doesn't provide
visual feedback to reflect its current state?
I used Spy++ to detect the EM_SETSEL message and the message
was correctly listed in the message window.
Can anyone give suggestion?
My current development tool is MSVS Community 2015, project type is Win32 that merely uses A.P.I.
modified 19-May-16 13:01pm.
|
|
|
|
|
I have just tried this (with VS 2010 Express) and it selects and highlights the text correctly. Can you show the exact code you are using?
As a suggestion, do not use the A or W suffixes on Windows API calls. Use the base name, without the suffix, and let the compiler generate the correct call based on your projrct's Unicode/ASCII setting.
|
|
|
|
|
I've tried to omit the suffix letter and it still produced the same effect.
Below is code that sends the EM_SETSEL message to the Edit control.
int selPos = (int)(pInitialFound - lpWStr1) + 1;
int selEnd = selPos + (lstrlenW(lpWStr0));
SendMessage(hwndEdit, EM_SETSEL, selPos, selEnd);
Are there any suggestions to better correct that problem?
modified 19-May-16 13:02pm.
|
|
|
|
|
programmingalholic wrote: I've tried to omit the suffix letter and it still produced the same effect. That's because the A or W is nothing to do with your problem. That is just a suggestion for better code writing, and you should fix it in all your programs.
As to the actual problem, what are the values of selPos and selEnd when the code runs?
|
|
|
|
|
The selPos is the value denotes the first character's position of the selected text and the selEnd is the value denotes the end character's position of the selected text.
Did any VS.Community users have the same experience like me?
|
|
|
|
|
programmingalholic wrote: The selPos is the value denotes the first character's position of the selected text and the selEnd is the value denotes the end character's position of the selected text. Seriously? Richard asked what their values were, not what purpose they served.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I know that. But have you actually used your debugger to check that they are both valid at the time of your SendMessage call? Is selPos >= 0, and selEnd > selPos && < editTextLen()?
|
|
|
|
|
The selPos and selEnd had actually referred to the precise character index of the selected text. Thanks.
|
|
|
|
|
As per Richard said debug the dam thing because there is something wrong with a value and you are asking us to guess what.
However something obvious to me which you have not explained you have two different string pointers in the above lpWStr1 and lpWstr0 and since there is something wrong with selPos or selEnd which you haven't debugged is this related as no explaination of these???
In vino veritas
|
|
|
|
|
programmingalholic wrote: Below is code that sends the EM_SETSEL message to the Edit control.
int selPos = (int)(pInitialFound - lpWStr1) + 1;
int selEnd = selPos + (lstrlenW(lpWStr0));
SendMessage(hwndEdit, EM_SETSEL, selPos, selEnd);
And what are the actual values of selPos, selEnd, and the length of the text in hwndEdit edit control?
|
|
|
|
|
|
the actual value of selPos and selEnd just represent as what they are, both contained int value that denoted character index. To hwndEdit, the return value of GetWindowTextLengthW just not false ( other values than 0 ).
|
|
|
|
|
programmingalholic wrote: ...to make it locates the searched text enter from the another Edit control. This is very unclear. Are you wanting to select text (EM_SETSEL ), or get the text that is selected (EM_GETSEL )? These are two separate problems, requiring two separate messages.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 20-May-16 9:27am.
|
|
|
|
|
I want to select text in the Edit control and make it has visual effect that represents the highlight of selected text. But how does WM_SETSEL come? It was undefined in the edition of my Visual Studio.
Any suggestion please??
modified 19-May-16 13:03pm.
|
|
|
|
|
programmingalholic wrote: But how does WM_SETSEL come? Do you mean how is it used?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
programmingalholic wrote: WM_SETSEL There is no such message.
|
|
|
|
|
The default behaviour of edit controls is showing the selection only when the control has the focus. From your description I assume that another control (the search input field or a button) has the focus when you try to set the selection.
But there is an option to show the selection even when the edit control does not have the focus: ES_NOHIDESEL[^].
Unfortunately the style can't be changed once the control exists. You have to set it when creating the edit control. If it is defined as static resource, set the option there (e.g. using the resource editor). For dynamically created edit controls pass the flag in the style parameter when calling CreateWindow or CreateWindowEx .
|
|
|
|
|
That's 100% right !! It had to do with ES_NOHIDESEL style, I had succeeded tap into it. However, thanks to all members of this community that had posed attention to my problem.
|
|
|
|
|
Hello Friends
I am creating 100s of buttons in Window application.I used naming like IDB_BUTTON1, IDB_BUTTON2..... IDB_BUTTON100.And assign variable m_button1.
Now, I want to convert string (m_button+ ID) to m_button1 of CButton type.
Regards
|
|
|
|
|
You cannot normally do that, generated resource IDs are numbers. You can use strings to refer to resources but it requires a detailed knowledge of resource files and the rc compiler. This also begs the question, why do you need so many buttons?
|
|
|
|
|
So many buttons are requirement of Application.
Actually, I tried with Macro. But ,again I need to use Variable value to identify 100 buttons tht macro doesn't consider variable.
I used like
#define CONCAT(ID,NUMBER) ID##NUMBER
And IN Code
for(int num =0; num < 100; num++)
CONCAT(m_Button,num)
So, this one fails.
|
|
|
|