|
okk hamid ...let me ask question one by one because i think i could not make my question clear.
first ques-->
i have some doubt in selectobject(di, o1) function, what i understand that it select object o1 in device context di and return new object.
am i right , if not then please help me to understand it.
second ques-->
in function "GetMaskBitmaps" in for loop you use ::SetPixel(hXorMaskDC,x,y,MainBitPixel); which set color in hxorMaskDC but in function "CreateCursorFromBitmap" you pass "iconinfo.hbmColor = hXorMask;" in Iconinfo structure. here i have confusion that when you set color in hXorMaskDC then how you update it in hXorMask.
it may be a stupid question but really i am confused in it.
third ques-->
in function "GetMaskBitmaps" after setting color value in for loop you used ::DeleteDC(hXorMaskDC);
::DeleteDC(hAndMaskDC);
::DeleteDC(hMainDC);
which shows that you have deleted these device context then how can we use it later in "CreateCursorFromBitmap" function.
these are only small doubt i have...
|
|
|
|
|
First is correct
it replaces new object with previous.
Second:
(iconinfo.hbmColor = hXorMask)=hXorMaskDC?
You made a handle bitmap hXorMask on the CreateCursorFromBitmap and its set to NULL then you pass this handle to GetMaskBitmaps on the last parameter GetMaskBitmaps(...,...,...,hXorMask);but I think you dont see declare of GetMaskBitmaps:
GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent,
HBITMAP &hAndMaskBitmap, HBITMAP &hXorMaskBitmap)
<br />
a little sample of & (address of operator)<br />
int i ; <br />
int& i2 = i;
i=100;<br />
<br />
int c=i2;
c=100;<br />
i2=100; <br />
i=100;<br />
Now I think you know why iconinfo.hbmColor= hXorMask; because after the loop you have ::SelectObject(hXorMaskDC,hOldXorMaskBitmap);
Third:
You must delete DC after finish wrok but this question is return to previous question and your answer is last parameter of this function
.....HBITMAP &hXorMaskBitmap)
before delete it has address of hbitmap.
(BTW one more thing about DeleteDC: if your DC is of GetDC() you cant use of DeleteDC and you must be use of ReleaseDC.;))
vikas choudhry wrote: these are only small doubt i have
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 )
|
|
|
|
|
so it means that the statment hOldXorMaskBitmap = (HBITMAP)SelectObject(hXorMaskDC,hXorMask); means that object "hXorMask" will get selected in "hXorMaskDC" and new object "hOldXorMaskBitmap" replace the old object "hXorMask".
so whatever change will be done in hOldXorMaskBitmap will get reflected in hXorMask??
i hope this will be my last question on this topic
|
|
|
|
|
Thats right and you cant select a bitmap into a dc more that one time and I said previous you replace new object with current object (return value of SelectObject).
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 )
|
|
|
|
|
thanks hamid...your post were really very helpful.
i have completed my task successfull and its working fine.
thanks and all the very best
|
|
|
|
|
Thank you vikas.
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 have loaded images in the Thumbnail dialog and also i have added background color. But in vertical scroll the dialog is not getting repainted.Can anyone please help me. I have enclosed the source code here.
<pre>
CBitmap Background;
CBrush BrushHol;
CSize bitmapSize;
In OnInitDialog,
ShowWindow(SW_SHOWNORMAL);
Background.LoadBitmap(IDB_BITMAP1);
BITMAP bm;
Background.GetBitmap(&bm);
bitmapSize = CSize(bm.bmWidth, bm.bmHeight);
In onpaint,
CDC dcMemory;
dcMemory.CreateCompatibleDC(cdc);
CBitmap* pOldbitmap = dcMemory.SelectObject(&Background);
CRect Client;
GetClientRect(Client);
const CSize sbitmap = bitmapSize;
cdc->BitBlt(0,0,sbitmap.cx,sbitmap.cy,&dcMemory,0,0,SRCAND);
dcMemory.SelectObject(Background);
In vertical scroll,
if( Background.m_hObject != NULL )
{
InvalidateRect(Client,TRUE);
}
|
|
|
|
|
I have loaded images in a thumbnail dialog and i added background color to thumbnail dialog.But in vertical scroll, Thumbnail dialog is not getting re-painted.can anyone please tell me how to repaint the thumbnail dialog during vertical scroll.
<pre>
CBitmap Background;
CBrush BrushHol;
CSize bitmapSize;
In initdialog
CDC dcMemory;
dcMemory.CreateCompatibleDC(cdc);
CBitmap* pOldbitmap = dcMemory.SelectObject(&Background);
CRect Client;
GetClientRect(Client);
const CSize& sbitmap = bitmapSize;
cdc.BitBlt(0,0,sbitmap.cx,sbitmap.cy,&dcMemory,0,0,SRCPAINT);
dcMemory.SelectObject(pOldbitmap);
in onpaint
CDC dcMemory;
dcMemory.CreateCompatibleDC(cdc);
CBitmap* pOldbitmap = dcMemory.SelectObject(&Background);
CRect Client;
GetClientRect(Client);
const CSize& sbitmap = bitmapSize;
cdc.BitBlt(0,0,sbitmap.cx,sbitmap.cy,&dcMemory,0,0,SRCAND);
dcMemory.SelectObject(Background);
in Vertical scroll
if( Background.m_hObject != NULL )
{
InvalidateRect(Client,TRUE);
}
</pre>
|
|
|
|
|
When our code, which is not Unicode, is used on a system with DBCS enabled (e.g., Japan), the typed text is not being retrieved from the edit controls properly. For lack of a better-formed question, must I do something special to the edit control (styles) or the code that retrieves the text from that control so that I get the correct text?
Thanks.
- DC
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
What kind of method to get the text of edit control?
GetWindowText?
What kind of text in the edit control?
ANSI or Japanese character?
There's nothing special.
|
|
|
|
|
I've tried SetWindowTextA(...,....) and SetDlgItemTextA(..,...) but nothing works. There must be a command somewhere where you can change on-the-fly messages contained in a Window Pane of a StatusBar. Does someone know how? I'm using VS2008, MFC.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Did you see CStatusBar::SetPaneText?
|
|
|
|
|
Yes that works! I don't know why I didn't see that command, but I'm glad you elightened me. Another question: Is there a way, to "on-the-fly",to enlarge a particular pane so that it fits the needed space for new text?
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: I n't know why I didn't see that command
Larry Mills Sr wrote: Is there a wait "on-the-fly" to enlarge a particular pane so that it fits the needed space for new text?
Larry, 50 minutes has passed between your posts. It would take you less than 5 to go read the documentation on msnd.microsoft.com for the class. Logically it's more productive for you to read the documentation than wait for answers in internet forums. So the 50 cent question here is, why do you refuse to read the documentation?
led mike
|
|
|
|
|
Okay, I checked out MSDN Lib rary on CStatusBar class. I found nothing explaining what command to enlarge the Pane for the new Text. Do you know where I can find that out?, or better still, what that command might be?
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: Okay, I checked out MSDN Lib rary on CStatusBar class. I found nothing explaining what command to enlarge the Pane for the new Text. Do you know where I can find that out?, or better still, what that command might be?
CStatusBar is not the same class as CMFCStatusBar .
led mike
|
|
|
|
|
Hamid. wrote: Did you see CStatusBar::SetPaneText?
They probably hide that in the documentation eh? Slimy bastards! They should be hung by their balls!
led mike
|
|
|
|
|
led mike wrote: Slimy bastards! They should be hung by their balls!
What makes you think they aren't already?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I noticed in MSDN under CMFCStatusBar that there is a SetPaneWidth() but How do you set a particular Pane's width using that command. if my pane is ID_PANE3 how would I set the width on it to fit the length of a CString? (I sure wished they would show examples of this stuff.)
A C++ programming language novice, but striving to learn
|
|
|
|
|
CPane::AdjustSizeImmediate[^]
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Yes I see that; but If my pane is ID_PANE3 how would I get focus on it and do this CPane::AdjustSizeImmediate() . How do I set the length(not Width) to equal(in pixels) to a CString?
(An example would be great.)
A C++ programming language novice, but striving to learn
|
|
|
|
|
What i'd try is to call that on the MFCStatusBar itself with TRUE as parameter, so something like:
my_mfc_statusbar.AdjustSizeImmediate(TRUE);
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
I find that using a function with various arguments uncovers a lot about its usage. Try something like:
mfcStatusBar.SetPaneWidth(ID_PANE3, 500);
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Program crashed on that command David.
A C++ programming language novice, but striving to learn
|
|
|
|
|