|
I am not so familiar with GDI+,so I don't know that the code your provided can wheather achieve my purpose definitely.What I mean is the region in the bitmap is not necessarily a rect,it is mainly region that I draw with mouse.So it is a irregular region.Could you get it?;P
|
|
|
|
|
Chen-XuNuo wrote: What I mean is the region in the bitmap is not necessarily a rect,it is mainly region that I draw with mouse.
You could create a GraphicsPath object from the mouse points defining the outline and then
use Graphics::SetClip() to set the clipping region to the GraphicsPath in the destination
Graphics object before drawing the bitmap.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
I have a dialog-based program,
I want to draw my own title bar,so I completement ON_WM_NCPAINT() message of the dialog.
In the OnNcPaint() funtion,I wrote:
CDC* pDC=GetWindowDC();
CDC memDC;
BOOL ret=memDC.CreateCompatibleDC(pDC);
int nSaveDC=pDC->SaveDC();
CBitmap bmp;
ret=bmp.LoadBitmap(IDB_LOGIN);//IDB_LOGIN is a bitmap resource ID
memDC.SelectObject(&bmp);
CRect rc;
GetWindowRect(&rc);
ScreenToClient(&rc);
ret=pDC->BitBlt(0,0,rc.Width(),m_captionRect.Height(),&memDC,0,0,SRCCOPY);
bmp.DeleteObject();
ReleaseDC(&memDC);
pDC->RestoreDC(nSaveDC);
the code works well when the dialog was shown first time,but when the dialog should be redrawn,the title bar went back to its default look(the blue bar).
Someone would like to tell me why?And how to resolve it?
Thanks.
GOOD LUCK.
|
|
|
|
|
i am not sure but it sounds like you need to send an update to your non-client area
Yours Truly, The One and Only!
|
|
|
|
|
Thanks.
Now,it works well.But if you would like to tell me how to make the client area's left-bottom and right bottom is round conor?
|
|
|
|
|
i'm afraid i have not done GDI and custom drawing in a sometime these days most of my development is focued on non-gui core development!
i am sure you should be able to find custom driawing how-to on this site understand mfc section, have you tryed that?
Yours Truly, The One and Only!
|
|
|
|
|
Thanks,but I has searched in this site faild.
GOOD LUCK.
|
|
|
|
|
ok here's how to do it if you're resourceful.
the first time around before you window come up you will have to grab the background and draw it into a z-buffer(off-screen buffer), only grab the rectangle area of the bottom portion you will need the round corned, follow me, then you do your non-client magic drawing in the bottom portion of your window!
that is the first step, the 2nd step once you get this working it to make it be able to grab area while your window is getting move around...remember to paint back the original screen background if that is required, most likely you will not have to worry about this last part.
hope that helps! remember just use the window DC and you will need to covert the between screen point and client point!
hope that help....learn to do this for yourself, you will be a better developer for it
Yours Truly, The One and Only!
|
|
|
|
|
I'm trying to convert and short int into 2 bytes to be send through an ethernet comm. This is what I'm trying to do:
char calcsendbuf[3];
short int data;
printf("Please Enter The Data:");
scanf("%d", &data);
calcsendbuf[0] = char(data % 256);
calcsendbuf[1] = char(floor(double(data/256)));
printf("byte 0: %u\n", calcsendbuf[0]);
printf("byte 1: %u\n", calcsendbuf[1]);
I input 32767 as the data and it should be printing 255 and 127, but I'm getting 4294967295 and 127. Any ideas of what is going wrong here, or maybe a different way of doing things?
Thanks
|
|
|
|
|
simoncoul wrote: I input 32767 as the data and it should be printing 255...
Since a char has a range of -128 to 127, trying to assign it a value of 255 will not do what you want.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You will never get 255 with a signed char, since chars are only 1 byte (your range is 2^7 both ways). Use the unsigned char instead.
|
|
|
|
|
Ok using the unsigned char worked for the display but the send function in winsocks asks for a char *, how do I go about getting sending a single byte of 255 through ethernet using winsocks.
|
|
|
|
|
To be honest, I have no clue. I won't pretend that I know anything about winsocks, but IF (and that's a big if) all it has to do is with type conversion, you can simply cast it on the send, and cast it back when you receive it.
|
|
|
|
|
Thanks for the help I took my unsigned char array and cast it as char * in the send function and it all works now.
Thanks for all the help!!!
|
|
|
|
|
Hi guy this is so lame i cant pass parameters between classes, i feel like commiting sucide (
anyways
I have used a public variable in say class A
Public:
long iSelPackageItemID;
and assigned the value in function...
setPackageID()
{
iSelPackageItemID=some value;
}
then i have declared a function
long getPackageID()
(
return iSelPackageItemID;
)
after a long long time i call the function getPackageID()
from some another class say B and i am getting garbage value i.e. getPackageID() is returning garbage.
Whatever is the solution i just want the value from iSelPackageItemID in class B which is assigned in class a.
|
|
|
|
|
Maybe you have casting problem. post the code when you call setPackageID from your B class (before taking any action for suicide )
|
|
|
|
|
No casting since all the variables are long. I checked in the debug mode that the value is retained in the class as along the variable is in scope, but garbage value is assigned once the value goes beyond the scope. I guess i need to increase the scope of variable to application variable.. How do i do it...?
|
|
|
|
|
I dont know how exactly u had written the class,
I assumed some and written like this..
class A<br />
{<br />
public: <br />
long iSelPackageItemID;<br />
<br />
A()<br />
{<br />
<br />
iSelPackageItemID=100;<br />
}<br />
<br />
setPackageID()<br />
{<br />
iSelPackageItemID=200;<br />
<br />
<br />
}<br />
long getPackageID()<br />
{<br />
return iSelPackageItemID;<br />
<br />
}<br />
<br />
<br />
};<br />
<br />
class B<br />
{<br />
public:<br />
A ob1;<br />
<br />
<br />
<br />
};<br />
<br />
int main()<br />
{<br />
<br />
<br />
B ob2;<br />
A ob;<br />
cout<<ob.getPackageID()<<endl;<br />
<br />
cout<<ob2.ob1 .getPackageID ()<<endl;<br />
<br />
<br />
<br />
return 0;<br />
<br />
}
if ur code is similar to this than u got the solution.
If this the right solution that ur problem is,
u had given some valsue to iSelPackageItemID in the setPackageID() method, but when u create the onject to class A or B, ur members functions will not call and the valuse of setPackageID is not intialised, so give valuse to setPackageID either in constructor or call the setPackageID() function before calling getPackageID()<< method.
|
|
|
|
|
Well i solved the problem time being.
by declaring
extern long iSelPackageItemID in the .h file
and long iSelPackageItemID in .cpp file
i got help from here http://www.codeguru.com/forum/showthread.php?threadid=427587
But the core OOP funda remains unanswered, i know this is going beyond the scope but just for knowledge sake. I am also working in java and i haven't seen such kind of syntax, also in a desingning book it stated not to use a global variable since it voilates the basic rules of OOP. So is the above code a good programming practise...?
|
|
|
|
|
How are you creating "some value"? The first thing that comes to mind is that it is a variable that has gone out of scope between when you assign it and when you try to reference it.
Judy
|
|
|
|
|
I am not clear on this thing ... but now it looks like pretty much that it's going out of reference. My OOP fundas are weak... but just one question when i assign a value to a class member A, then i declare an obj of class B so when i try to access the member from a through B does it go out of scope..?
|
|
|
|
|
I'm not saying that the member itself of class A goes out of scope, I'm suggesting that what was assigned to the member went out of scope. The member itself is still good but it is referncing memory that is no longer good .You see this a lot with objects created on the stack. For example:
char *MyCreateFunc ()
{
char buffer[256]
// do all the stuff to fill in buffer
return buffer;
}
The statement
A::m_memberVar = MyCreateFunc ();
will compile and execute and may even work as expected sometimes. However, it is wrong!! A::m_memberVar remains in scope but what it points to is no longer in scope because the memory containing the data is no longer valid once the MyCreateFunc returns.
Show the code where you create the value assigned to the member of class A. The member variables of a class remains in scope until the class itself goes out of scope, so unless you're accessing class A incorrectly, the problem has got to be in the value assigned to the member variable.
Judy
|
|
|
|
|
I have an application in visual c++ relating to client and server. this appliaction does many types of work like getting all user names logged on to computers,remote shutdown,remote logoff, getting the remote desktop view and many others types of functioning related to "lan monitoring" through server. but for this , client application has to be executed all the time whenever any user logon through his local account.
but the problem is that I couldn't find any way to execute the "client exe" automatically whenever any user logon through his/her local account.But I could execute the client exe automatically for the administrator by making changes in the registry but I have to execute it "for all users".
So please help me to find any way to execute the client exe for all users automatically whenever they logon through their local account.Is there any win api or by making any registry changes or any program which can call the exe automatically whenever any user login.
ps:since this is all a part of a domain so all the other users are less priviliged than admin
HELP HELP URGENT SITUATION
RAHUL CHHABRA
|
|
|
|
|
Why not just add it to the Startup folder for All Users?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The application you are describing would seem to operate best as a service.
Check out "Start Your Windows Programs From An NT Service" by Xiangyang Liu. This article seems to be very popular here on codeproject.http://www.codeproject.com/system/xyntservice.asp[^]
Best Regards,
Randor (David Delaune)
|
|
|
|