|
thanks alok
alok can you please describe it in more details that how would i load a bmp file from system to attach it to cursor.
|
|
|
|
|
hey i am very new to it...so please can somebody help me out in this. please give me direction how to proceed for it.
|
|
|
|
|
You need to use of LoadCursor or CreateCursor and then use of theri handle on the SetCursor.
|
|
|
|
|
i used LoadImage as i need to load a bmp image directly from a location in my machine and then pass the handler in setcursor but it didn't work.
please help me.
|
|
|
|
|
|
thanks hamid.
but i think what i need is something diffrent from it.
my requirement is that when we press a button a browser window opened and from there we choose a bmp image which after selection become mouse cursor.
may be as i am new in this that's why i am taking so much time to understand it.
please teel me the way that how to achieve it , i mean how to attach icon on cursor in this way.
|
|
|
|
|
Did you see that article it was good point for start I think you want to use of dynamic bmp or icon files for cursor,right?
(BTW dont forget to give votes to my posts).
|
|
|
|
|
yes it was really a good article but i could not relate it with my requirement.
yes you are right i want to use bmp icons dynamically.
(i assure you that i will give vote to all your posts )
|
|
|
|
|
So whats wrong see GetMaskBitmaps on that article you can be read your bmp file of anywhere cd/hard or resoruce of your project,you need to a handle(hbitmap) then GetMaskBitmaps converts its color to 0..255 for height and width (its a suggestion dont use of hight bmp files for example 1024x768 because you must be wait for long time and answer is light for two loop on that article.)
|
|
|
|
|
hmm..okk...i do more deep study of your artice and even after that i wont get any solution then i wont hesitate to ask you for further help
|
|
|
|
|
You can ask of me and I will be glad of help to you.
|
|
|
|
|
hii hamid
i have tried it but i got stucked one place.
you have used "m_hSourceBitmap = GetCursorBitmap();" in function "void CColorCursorTestDlg::OnCreateCursor() " but how will i get bitmap of my bmp image which is stored somewhere in hard disk.
i tried Loadimage but it was returning null , i dont know why but it is not working.
tell me the way ..how to proceed
|
|
|
|
|
If you are using of bmp files LoadImage must be work I think you need to change some parameters on the LoadImage but I suggest CImage class like this
#Include AtlImage.h
CImage m;
m.Load(_T("c:\\1.bmp"));
HBITMAP hbit=m.Detach();
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 tried much but still "Loadimage" function is returning null. my application is in VC 6 and its not finding that header file "AtImage".
my code is like
static void C_FAR S_Win1_mousein L1(App1Win1Ptr, win)
{
HANDLE handle;
ImagePtr image;
handle = LoadImage(0, "E:\images3.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SetCursor( handle);
WGT_SetBgColor(win->SArea1, COLOR_Red());
}
i am trying to load that cursor during run time.
|
|
|
|
|
thanks hamid i successfully completed my task. your post were really very helpful.
i just want one more favour that how you update fields of parameter which you pass in Iconinfo. i.e. hAndMaskBitmap and hXorMaskBitmap as in function "GetMaskBitmaps" you fill "hAndMaskDC" and "hXorMaskDC" with masking bit value in that for loop. so how these value stored in hAndMaskBitmap and hXorMaskBitmap.
please clear this concept to me as it will be really very helpful to do further work in same area.
|
|
|
|
|
You have two memory device context (hAndMaskDC" and "hXorMaskDC) and two compatible bitmap with device (hAndMaskBitmap,hXorMaskBitmap ) on the loop you use of SetPixel for set pixels to specified colors
::SetPixel(hAndMaskDC,x,y,RGB(255,255,255)); or ::SetPixel(hXorMaskDC,x,y,MainBitPixel); with two loops for height and width and finally SelectObject because you want to select this object into the device context that you made it.
(I dont know it was your answer or it was my mistake of your question. ).
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 )
|
|
|
|
|
It seems for this question I came late!
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 )
|
|
|
|
|
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>
|
|
|
|