|
I have created a push button in a Toolbar. I want to add image to this button.How can i do this.
|
|
|
|
|
Did you see CToolBar::LoadBitmap?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I want to add for a particular button
|
|
|
|
|
Source code:
CButton btn;
btn.Create("TEST",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,rect,m_ToolBar,ID_BTN);
m_ToolBar.SetButtonInfo(21, ID_BTN, TBBS_PUSHBUTTON, IDB_CANCEL);
|
|
|
|
|
Is it possible to add image
|
|
|
|
|
I suggest you to look in here[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
if ((nFlags & MK_LBUTTON) && (this == GetCapture()))
{
m_SecondPoint = point;
if (m_pTempElement)
{
m_pTempElement->Draw(&aDC);
delete m_pTempElement;
m_pTempElement = 0;
}
m_pTempElement = CreateElement();
m_pTempElement->Draw(&aDC);
}
This is a code of a message handler in a drawing application which now supports drawing lines, rectangles and circles.
We save the first cursor position in the Mouse button down handler
The CreateElement() creates an element (rectangle, circle, line, curve) on the heap and returns a pointer to it.
I don't understand why do we need to redraw the old element. Like I created an element and then a mouse move occurs then why do we draw it two times? First, in the inner if block and second, after the if block.
It is drawing over the previously drawn element in the inner if block right?
|
|
|
|
|
Please elaborate.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Looks like the Draw method is using an XOR pen, which is a common method for drawing shapes. An XOR operation is similar to inverting the colours, so by drawing it the second time, you effectively erase the old shape before drawing the shape at the new position.
|
|
|
|
|
I have a property page with a static control area defined as
CONTROL "",IDC_TEMP_GRPH,"Static",SS_GRAYFRAME,154,44,135,129
I am handling WM_PAINT message and the following piece of code gets executed:
CDC* pDC = new CDC(GetDC(this->m_hWnd));
HWND hStatic = GetDlgItem(m_hWnd,IDC_TEMP_GRPH);
RECT pirect;
GetClientRect(hStatic,&pirect);
COLORREF bkColor; bkColor = RGB(225,0,0);
HBRUSH hBrush = ::CreateSolidBrush(bkColor);
::FillRect(GetDC(hStatic),&pirect,hBrush);
The problem is I am not able to see this solid color block. It appears blinking while I drag the Property Sheet but disappears when I switch to next page and switch back to that page. Can anyone please tell me what is missing here?
|
|
|
|
|
Rather than painting from your dialog, try over-riding the static control.
Have a look at this article:
http://www.codeproject.com/KB/miscctrl/generic_picker.aspx[^]
It's not talked about in the article itself, but it uses an owner draw static control to do the pretty picture bit. Feel free to stealreuse it from me.
Iain.
|
|
|
|
|
Got my 5 , thank you for posting it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks. I've got so much useful code from CP, I like to give back when I can.
I hope you've added yourself to pointy haired thread hijackers list...
Iain.
|
|
|
|
|
Iain Clarke wrote:
I hope you've added yourself to pointy haired thread hijackers list...
Well, since I'm (together with Rajesh) the proud founder of the Brigade, my name is necessarily there.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks. But I foound out what was missing from my code. I had to add
PAINTSTRUCT ps;
HDC hdc = ::BeginPaint(m_hWnd, &ps);
at the start and
::EndPaint(m_hWnd, &ps);
at end of my code snippet and it works.
|
|
|
|
|
First, use CPaintDC in the WM_PAINT message handler, not GetDC, and second, when you do this:
GetClientRect(hStatic,&pirect);
You get the client area of the static, not its position in the client area of its parent. If you want to know where the static lies inside of its parent use some coord mapping functions or simply this:
RECT pirect;
GetWindowRect(hStatic,&pirect);
ScreenToClient(&pirect);
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
I am using SDK so CPaintDC is ruled out. So I have to add BeginPaint() and EndPaint() instead fro it to work.
|
|
|
|
|
Hi,
i want to change the button label (ok,save) of native dialog box.
OPENFILENAME C_FAR *ofn;
fileW = FILEW_Create();
FILEW_Init(fileW);
fileW = FILEW_DefFileW();
ofn = (OPENFILENAME C_FAR *)PTR_New(sizeof(OPENFILENAME));
ofn->lStructSize = sizeof(OPENFILENAME);
ofn->lpstrTitle="Rajib";
ofn->hwndOwner = ((win != (WinPtr)NULL)) ? MSW_WgtGetWWindow((WgtPtr)win) :(HWND)NULL;
ofn->Flags |=OFN_EXPLORER;
GetOpenFileName(ofn);
PostMessage((HWND)fileW,(UINT) CDM_SETCONTROLTEXT,(WPARAM)IDOK,(LPARAM)"hi");
i have used this code and trying to set OK button's label as "Hi" but not being able to do the task.
Can some one help me?
Vikas
|
|
|
|
|
|
Use the CFileDialog class and overwrite its OnInitDone() method and use GetDlgItem to find the button (IDOK) and try to change its text.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Hi Thanks for your suggestion
now my query is if i use GetDlgCtrlID
then kindly suggest me
GetDlgCtrlID(HWND hwndCtl);
what should i pass in hwndCtl(is it dialog box's handle/some thing else).
Regards
Vikas
|
|
|
|
|
Are you sure you want to use GetDlgCtrlID and not GetDlgItem ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
hi,
MY OBBJECTIVE IS THAT I HAVE A BUTTON IN A WINDOW.
ON CLICK EVENT ON THAT BUTTON I WANT TO SHOW THAT DIALOG FOR WHICH I WANT TO CHANGE THE CAPTION OF BUTTONS(ok,save).
so what procedure should i follow
|
|
|
|
|
Don't yell.
I think the answer has been given to you already, or you mean it doesn't work?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Hi,
i tried GetDlgCtrlID and GetDlgItem in the init of dialog.
but in both cases it returned id as 0(zero).
For save as dialog box the button label is Save and for open dialog it is Open.
so where should i get the corresponding ids of the same.
i have tried
SendMessage((HWND)fileW,(UINT) CDM_SETCONTROLTEXT,IDOK,(LPARAM)(LPCTSTR)'hi');
to set the OK button's labels as Hi but in case of Open/save dialog there is no button which hold's the label as Ok.
Can you suggest me if i am doing wrong?
Rajib
|
|
|
|