|
This is a little work:
http://www.codeproject.com/staticctrl/LayeredBitmapCtrl1.asp
or look yourself for "transparent"
Greetings from Germany
|
|
|
|
|
There ia a GDI function called TransparentBlt() , but it is not very good. The best approach is to use two bitmaps. The first should be black in all areas you want transparent and white in all other areas. The secon, your picture, should be white in all areas you want transparent. You draw these two over the top of each other. The fist bitmap using BitBlt() with SRCAND , the second using BitBlt with SRCPAINT . The result is a transparent bitmap.
|
|
|
|
|
Actually, the easiest possible way of doing this is probably by just using an ImageList to draw your bitmap, specifying a mask color.
|
|
|
|
|
ok thanks all, i will try all the methods, and read the site as well..
thx..
|
|
|
|
|
Hi,
I am making a custom crash handler for application, and just thought about something.
I am using sprintf, strcat and strlen in handler, are they safe to use even after possible heap corruption?
|
|
|
|
|
chilituna wrote: I am using sprintf, strcat and strlen in handler, are they safe to use even after possible heap corruption?
That would depend on if they were operating on heap variables or not.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In general, after the heap has been corrupted all bets are off.
Steve
|
|
|
|
|
chilituna wrote: am using sprintf, strcat and strlen in handler, are they safe to use even after possible heap corruption?
better not try that! you will in great trouble!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi, thanks for answers..
Went throught source code of those (sprintf, strcat, strcpy and strlen) and it seems sprintf is unsafe, since it uses malloc, but strcat,strcpy and strlen are so simple and straightforward and they don't use heap so they are probably? ok..
Well, have to replace sprintf with strcpy,strcat,strlen combination..
|
|
|
|
|
i intialised buttons with color and icon on that button in OnIntilaUpdate()
function.
at first running the application the icons and colors are shown. I changed that view with some other view. Now i r eplace the olde view but the icons and colors are not shown . Now what to do show always icon and color
Can u explain PLZ?
|
|
|
|
|
kiranin wrote: i intialised buttons with color and icon on that button in OnIntilaUpdate
How you have done this?
I guess, you need to write that code in OnDraw, because OnIntilaUpdate get called once, and subsequent painting operation overrides, what you have done there.
|
|
|
|
|
I included one CButtonSt class from one of the samples in code project.
I tried it OnDraw but i got assertion failure....
|
|
|
|
|
Can you show some code, causing this to happen ?
|
|
|
|
|
<br />
void CFirstLook::OnInitialUpdate() <br />
{<br />
CFormView::OnInitialUpdate();<br />
<br />
<br />
<br />
<br />
m_btnApps.SetIcon(IDI_ICON2);<br />
<br />
m_btnApps.SetColor(2,RGB(128,128,128),FALSE);<br />
m_btnApps.SetColor(0,RGB(255,0,0),TRUE);<br />
<br />
<br />
}<br />
void CFirstLook::OnDraw(CDC* pDC) <br />
{<br />
<br />
<br />
<br />
<br />
}<br />
If i put it OnDraw i got assertion Failure.
I put it in Class contstructor i got assertion failure
but i ignore this i got the form window and after clicking on that button
am gettiong icon.
|
|
|
|
|
when you your code you get this error?
|
|
|
|
|
I got this error when i changed my views in different panes
|
|
|
|
|
did you used from debugger?
|
|
|
|
|
kiranin wrote: included one CButtonSt class from one of the samples in code project
You better post this to article, where you get this sample from.
As nobody know, how CButtonSt looks like.
kiranin wrote: I tried it OnDraw but i got assertion failure....
Where it taking to you, in code.
|
|
|
|
|
hi all,
I have dynamically created a CEdit Control in the Dialog. When ever i Right Click in the EditBox i have to show popup a Menu. Then I select the FirstMenu Item from Menu must show a CColorDialog and choose a Color and store it in a COLORREF variable. This is done using TrackPopupMenu(...) when ever i Right Click in the Newly Created EditBox Dynamically.
after choosing the Color from the ColorDialog Box. That Color Must be Reflected in the Edit Box where ever i RightClicked.
//===========================================================================
void CExpDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CClientDC *dc = new CClientDC(this);
ptr = new CEdit; //Create Dynamic Edit Control Here
ptr->Create(WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP|ES_AUTOHSCROLL,CRect (point.x,point.y,point.x +100, point.y +20),this,ctr++);// Dynamic Edit.
CDialog::OnLButtonDown(nFlags, point);
}
HBRUSH CExpDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch (nCtlColor)
{
case CTLCOLOR_EDIT: //For General EditBox. here i am bit confused
pDC->SetBkColor(c); // where c is COLORREf selected in ColorDialog
break;
}
return 0;
}
//This when ever i right Click on the newly Created EditBox Item.
void CExpDlg::OnParentNotify(UINT message, LPARAM lParam)
{
if(message == WM_RBUTTONDOWN)
{
CPoint pt(LOWORD(lParam),HIWORD(lParam));
PopupMenu (&pt);
}
}
//Populate the Menu Item
void CExpDlg::PopupMenu(CPoint* pt)
{
ClientToScreen (pt);
CMenu FloatingMenu;
FloatingMenu.LoadMenu(IDR_MENU1);
CMenu* pPopupMenu = FloatingMenu.GetSubMenu (0);
pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt->x, pt->y, this);
}
//This is the Menu Item when the TrackPopUp is Shown.
void CExpDlg::OnObjetsOne()
{
CColorDialog dlg;
if(dlg.DoModal()== IDOK)
{
c = dlg.GetColor(); // c is the ColorRef of the ColorDialog.
}
}
Here the New color what i am choosing is not Reflected to the EditBox which i Created Dynamically.
please provide me a solution.
//===========================================================================
Uday kiran
|
|
|
|
|
uday kiran janaswamy wrote: Here the New color what i am choosing is not Reflected to the EditBox which i Created Dynamically.
How you want to use this color in CEdit variable. What do you mean by not reflected to the EditBox?
|
|
|
|
|
hi prasad,
when i choose the color from the Color Dialog that Color Must be Reflect to the EditBox.
I mean when i Created the EditBox in LButtonEvent. Then i Right Click on the EditBox then a Popup Menu is being populated. then select the first MenuItem to Display the ColorDialogBox.
In that we choose the Color and store it in COLORREF. In our Instance it variable c.
That variable Color Must Reflected in the EditBox BackGround Color.
Uday kiran
-- modified at 8:28 Thursday 24th August, 2006
|
|
|
|
|
you need to return brush of that color in OnCtlColor
|
|
|
|
|
hi prasad,
That also i have done please look at my First Post.
thanks
Uday kiran
|
|
|
|
|
uday kiran janaswamy wrote: That also i have done please look at my First Post
I reallize that.I modified my post,too. It's always better to use pre tags for code. It makes code readable. I just missed it, on this occasion.
You code in OnCtlColor could be like this,
HBRUSH CExpDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch (nCtlColor)
{
case CTLCOLOR_EDIT:
{
hbr=CreateSolidBrush(c);
return hbr;
}
}
return hbr;
}
-- modified at 8:41 Thursday 24th August, 2006
-- modified at 8:51 Thursday 24th August, 2006
|
|
|
|
|
Hi prasad,
even i modified the code after set focus to the newly created editbox the effect is being shown.
please loot at it.
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch (nCtlColor)
{
case CTLCOLOR_EDIT:
{
m_redbrush.DeleteObject();
m_redbrush.CreateSolidBrush(c);
pDC->SetBkColor(c);
hbr = (HBRUSH) m_redbrush;
}
}
return hbr;
}
Uday kiran
-- modified at 9:15 Thursday 24th August, 2006
|
|
|
|