|
There is no builtin functionality that does that. You will need to make an ownerdraw list box. drax_0815 gave an example how to do that.
John
|
|
|
|
|
Do you want to set color for each character?
|
|
|
|
|
|
I dont know why you want to use it anyway its possible but you need to a little work:
1-you need to derived CListBox and declare WM_DRAWITEM on it (if you dont know how to use it you can see previous links)
2- On WM_DRAWIEM when you want to write items with TextOut or DrawText you must declare a loop
for each item for example you have three items on your listbox "one" "two" "three"
you get your string and when you want to show these items you need to a loop like this
for(int i=0;i<m_Str.GetLength();i++)
{<br />
SetTextColor(RGB(0,0,120));
pDC->TextOut(you need to calculate x,you need to calculate y, m_str[i]); <br />
<br />
}<br />
|
|
|
|
|
All I can say is, that you have to set your listbox to ownerdraw.
(fixed) if all listbox items have the same height an width.
Then you have to handle inside the message loop the MeasureItem and the WM_DRAWITEM
messages:
<br />
case WM_MEASUREITEM: <br />
<br />
lpmis = (LPMEASUREITEMSTRUCT) lParam; <br />
<br />
lpmis->itemHeight = 18; <br />
return TRUE; <br />
<br />
case WM_DRAWITEM: <br />
In the WM_DRAWITEM case you have to implement the tricky part (adding the text in different colors)
May a little help for google search.
|
|
|
|
|
I have developed a solution that has Help files and about 12 dialogs. The application is a MFC C++ 2005 Net based program.
Now I want to copy this and modify it for a new similar application. The original is not generic enough at present.
My question is (each time I have done this before, its been a fight to get all the name references corect). I would like all the main files (.cpp and .h) to take the name of the new application; e.g. Current solution is called ABC_123 and would like the new application to be QWERTY_123. The classes and other files are OK; its just the Main. I can change the diaglog titles etc, but also the Help needs to change?
How or what is the best way to rename the items in this solution?
Cheers,
Andy.
|
|
|
|
|
Is this[^] helpful for you
|
|
|
|
|
I have a audio file. I wanto to add a wave format header to it.
How can i do this? Please help.
Thnak you
KIRAN PINJARLA
|
|
|
|
|
I saw an article for this purpose on codeproject but its C#
|
|
|
|
|
I want to display a Message box to the user for some time only without waiting for its reponse i wish to move ahead
How to achieve this . Please help me out
|
|
|
|
|
anjita wrote: Message box to the user for some time only without waiting for its reponse
See here for some help on timed message box.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
anjita wrote: I want to display a Message box to the user for some time only without waiting for its reponse i wish to move ahead
In addition to what has already been suggested, I have always liked the look of Balloon help, Esp. for informational stuff. See Balloon Help as a non-modal replacement for MessageBox()[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
I have a a window and a button enclosed in it. The button is resized to fit to the window size initially. My problem is if i resize the window, the size of the button also shud resize so as to fit the parent rect. Is it possible?
|
|
|
|
|
The following two articles will be helpful to you.
http://www.codeproject.com/useritems/SizingDialog.asp
http://www.codeproject.com/dialog/easysize.asp
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Sure - catch the event when your window resizes, and call SetWindowPos on the button. The last parameter you want in SWP_NOZORDER, as you don't want to change that.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
See Here[^]. I just did it for an edit window. You can do similarly for a button.
you can also handle the WM_SIZE message.
What is the type of application that you are working on?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
my requirement is like this.. i have to simulate a buton which can be moved as well as resizable. It shud not get a feeling like its enclosed in a dlg.
|
|
|
|
|
SKMukherjee wrote: i have to simulate a buton which can be moved as well as resizable.
Handle WM_SIZE message in your window, the handler function will have two int parameters which has the window width (cx) and window height (cy). Say you have control variable for your Button (like, m_myButton), use it to resize your button as,
m_myButton.MoveWindow(0, 0, cx, cy)
or
m_myButton.SetWindowPos(&wndTop, 0, 0, cx, cy, SWP_NOZORDER)
Hope this will help you...
Do your Duty and Don't expect the Result
|
|
|
|
|
SKMukherjee wrote: My problem is if i resize the window, the size of the button also shud resize so as to fit the parent rect. Is it possible?
See the Extras section of this article.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
HI,
My application MDI application,i have different views,
when i click one option(example:go to page1) then it has display that particular page1.
It displays as it is...but it repaint on the old page and displayed..but i have to get the new page as a seperate window(like pop up) with resizing bar..like that..Pls help me out?
-- modified at 6:33 Thursday 28th September, 2006
Anu
|
|
|
|
|
Im sorry but I dont understand what you say?
|
|
|
|
|
Hi,
I'm having some problem with SendMessage/PostMessage API simulating a "click" on the [SAVE] button on IE's Download Dialog Box. Would appreaciate any sort of suggestions. Thanks
Scenario:
Clicking on a hyperlink (link to a file, e.g Try.xls) in Internet Explorer. A Dialog appear with 3 options, [Open],[Save],[Cancel]
Code Snippets:
BOOL bResult = FALSE;
HWND MainDialog = NULL, SaveButton = NULL;
MainDialog = FindWindow(NULL,"File Download");
if (MainDialog == NULL)
printf("Cannot Find Main Save DialogBox.\n");
else
{
SaveButton = FindWindowEx(MainDialog, NULL, NULL, "&Save");
if (SaveButton == NULL)
{
printf("Cannot Find Save Button.\n");
exit(0);
}
else
{
SetFocus(SaveButton);
bResult = PostMessage(SaveButton, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(0,0));
if (!bResult) exit(0);
bResult = PostMessage(SaveButton, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(0,0));
if (!bResult) exit(0);
}
}
Problems:
When I'm stepping through this step: PostMessage(SaveButton, WM_LBUTTONDOWN.. , I can see the button in depressed mode, and the Focus has been changed to the [Save] Button. But on Buttonup, nothing happens.
Tested Method (But I might have done it wrongly):
1. Have tried SendDlgItemMessage API and using GetDlgCtrlID to get the ControlID of the [Save] Button (Have verified using Spy++, and they are same). But it doesn't work.
2. Tried to send TAB key to the DialogBox, and the focus shift to [SAVE] button. But sending "Space" keystroke to the dialog also have no effect. (Can see the button moving, but nothing happens after that)
4. Tried changing the Default button from [CANCEL] to [SAVE] and sending SPACE KEY. Doesnt work.
-- PostMessage(MainDialog, (UINT) DM_SETDEFID, (WPARAM) GetDlgCtrlID(SaveButton) , TRUE);
3. On the other hand, when I try to activate the [Cancel] button, it works correctly.
Findings: (using Spy++)
1. I noticed that the [CANCEL] button has a ControlID of 000002, whereas the [OPEN] button and [SAVE] button has ControlID of 00001147 and 00001148 respectively. This probably means that [OPEN] and [SAVE] are not "default buttons". Therefore using VBScript, I tried - Msgbox "HelloCodeProject",vbYesNoCancel. [YES] button has ControlID of 6, [NO] had ControlID of 7 and [CANCEL] had Control ID of 2.
Apart from IE's Download Dialog Box, there are several other application that cannot be controlled using the SendMessage. Would appreciate any sort of suggestion.
By the way, using VBScript AppActivate, and SendKeys method is able to successfully activate the [SAVE] button, but that's not the way I want.
|
|
|
|
|
Have you tried sending the button a BM_CLICK message? What about using SendInput() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Good day Mr David,
I have tried BM_CLICK. But still it doesn't work.
As for SendInput, I understand from the API that it inserts events into the keyboard or mouse input stream. This probably means that if the focus is changed from the [SAVE] dialog box to other program, it might not work because at the same time, a few other automation tools will be running as well. This is why the WShell AppActivate and SendKeys function would not work when the focus is changed to other program.
Nonethelss, I would still try it out.
And thanks for the suggestions.
Would appreaciate more suggestions. Thanks you.
|
|
|
|