|
|
CRect rc;
GetClientRect(&rc);
rc.top=rc.bottom-48;
CBitmap bmp;
bmp.LoadBitmap(IDB_48x48);
CBrush br(&bmp)
pDC->FillRect(&rc,&br);
The topleft point of the rectangle is not the topleft point of the bitmap.
How to solve the problem?
Thanks.
|
|
|
|
|
From "Programming Windows with MFC, Second Edition" (Jeff Prosise).
Adapt the sample as you need for your code.
// Always set the same relative starting point for hatched brushes
CPoint point(x1,y1);
dc.LPtoDP(&point);
// Modulo of 8 since values should be 0 thru 7
point.x%=8;
point.y%=8;
brush.UnrealizeObject();
dc.SetBrushOrg(point);
dc.SelectObject(&brush);
dc.Rectangle(x1,y1,x2,y2);
|
|
|
|
|
Yes, I've just tested it, it works.
But why modular of 8? I just ignored it, there seems no problem.
|
|
|
|
|
From MSDN:
CPoint SetBrushOrg( int x, int y );
CPoint SetBrushOrg( POINT point );
Parameters
x = Specifies the x-coordinate (in device units) of the new origin. This value must be in the range 0–7.
y = Specifies the y-coordinate (in device units) of the new origin. This value must be in the range 0–7.
point = Specifies the x- and y-coordinates of the new origin. Each value must be in the range 0–7. You can pass either a POINT structure or a CPoint object for this parameter.
|
|
|
|
|
Remember that you may be getting a false positive if things line up correctly now. You might choose to write off the need to perform the modulus now but I would recommend doing it so that future uses of the code snippet that might be used with scroll bars, transformations, offset origins won't suddenly throw you a curve ball.
At least leave it in there, commented out, to remind you if that day ever comes.
|
|
|
|
|
Hello friend,
I have created a MFC Dialog based application and launches it using service when PC boots.
When I run my application on WinXp with IE6.0 it runs fine.
But, I run my application on WinXp with IE7.0, [logon/logoff/restart/shutdown] all WinXp standard functionality doesn't happens.
But when i kill my application and then try, all WinXp standard functionality works fine.
Please give me a solution that i can run my application using service and it solves IE7 problem.
I am currently using VC++6.0,Platform SDK SP2.
abhi
|
|
|
|
|
AbhijitAkude wrote: But, I run my application on WinXp with IE7.0, [logon/logoff/restart/shutdown] all WinXp standard functionality doesn't happens.
Does this mean that Windows is not shutting down when your application is running?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, Window not restarting or shutting down. It happens with any application creates using "MFC AppWizard exe".
abhi
|
|
|
|
|
By chance are you intercepting the WM_QUERYENDSESSION message?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
WM_QUERYENDSESSION and WM_ENDSESSION both are absent in my apllication.
The scenario on my PC:
i)I have 3 Administrator user and one limited user.
ii)run MFC application using service while PC boots on system account.
ii)Now,I am logged in 1st Administrator, and Switch in 2nd user without log off, repeats the same procedure for other accounts.
iii)Now try to log off/reboot.Windows Log off/reboot doesn't work.
abhi
|
|
|
|
|
Hi,
I have created an OpenGL window and can draw on it fine in the same thread as the one that created the window and processes the message queue. If I move the gl code to another thread, it does not draw anymore.
Does anyone know if this is possible?
thanks,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
From what I've read in every place I've seen, this doesn't really work, as in drawing from one thread into another thread's hwnd, at least it's not supposed to be done that way. And from my own attempts to do it before I read it windows handles got quite mixed up in the process and nice amount of asserts in MFC code. But as I wrote this was basic MFC app and cannot vouch it is totally true for you.
Basicly what you would do is do the work in a thread and message the window owner to do the drawing with the params you calced.
|
|
|
|
|
Hi everybody,
i'm trying to export a variable (integer) from a c++Win32 Dll to VB.
Later on an enum and a class !
Exprting functions is no problem but the rest !???!
Could you explaim what the .def file and the Vb code have to contain (code).
Btw. do you know good books or tuts which cover these problenms ?
I only have heared from this book :
"Professional ATL COM Programming" von Dr. Richard Grimes
thanks very much for your help
Croc
|
|
|
|
|
classes?
I think you have to go through COM and export interfaces rather than instances of classes.
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.
[my articles]
|
|
|
|
|
Hello,
What is the best way to export/save list items from a CListControl to file?
To read list line by line and export to file can be slow if i have many items in list, right?
I expect to have more then 50000 items in list, and there are 24 columns!
Please give some suggestion about this problem!
Thanks for any help!
termal
|
|
|
|
|
IMHO, there is something wrong with your design. The list control should be used only to display information, not to store it. Typically the data is stored somewhere in your document class (in case you are doing a SDI application) and is only displayed in the list control.
So if you want to save it, you don't interract with the list control.
If possible, try to separate the 'logic' and data storing from the way it is displayed.
|
|
|
|
|
Hi,
thank you for answer, i undersand what you mean!
regards
termal
|
|
|
|
|
BTW, if you need to insert so much data in your list control, it will probably be quite slow. I think (I'm not sure because I don't use this control a lot) that you can use a virtual mode. Instead of putting all your data into the control, you let the control ask your program what to display. In this way, only what is currently visible will be 'asked' by the control which should be faster.
|
|
|
|
|
You can use of a thread or timer for read and insert values to listctrl and you can use of CFile for save these values.
|
|
|
|
|
Some Windows filestore-explorer-type folders have on their left edges a displayed tree of folder and file names. The nodes of this tree can be collapsed and expanded by clicking on the node points.
Please, is there a function that I can call to make such a tree (not necessarily of folders and files) appear in a Windows program that I write?
|
|
|
|
|
MFC enabled developer? Go through CTreeCtrl class [^].
No MFC ? Use Tree View API [^].
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.
[my articles]
|
|
|
|
|
You want to use of CTreeCtrl,and if you search on the codeproject you can find customize treectrl.
|
|
|
|
|
Hi all,
In Visual Studio 2005, from one method in dll, I'd like to search the way how to find out the name of dll where this method is.
e.g.
TEST.dll
In TEST.dll, I've some methods like method1
and from method1, how can I find out the name "TEST.dll"
Many thanks in advance
Hope to hear the help soon.
|
|
|
|
|