|
Why wouldn't you use a custom window for that?
|
|
|
|
|
Custom window means what exactly you want to suggest.
|| ART OF LIVING ||
|
|
|
|
|
shivditya wrote: I am not getting device context
of dialog window properly
You can draw on the dialog just like any other window.
GetDC() gets a DC to the client area of the window
GetWindowDC() gets a DC to the entire window
If you draw in response to WM_PAINT, BeginPaint()/EndPaint() can be used to acquuire a DC
or you can use the above APIs and handle the invalid region yourself.
If you draw in response to WM_ERASEBKGND, a DC is provided.
There's no threadsafe GDI - all drawing must be synchronized (and flushed) if you're using
multiple threads for drawing.
shivditya wrote: and it crashes at ::GetWindowRect Of groupbox
Crashes how and why?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thats what I am also surprised how ::GetWindowRect crashes when my Id is proper, and I am passing handle which I checked with spy as proper ,Still it crashes very badly.
|| ART OF LIVING ||
|
|
|
|
|
GetWindowRect takes an HWND not an ID. How are you calling it? Where are you calling it?
Do you have a valid HWND for the control?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I am very sorry yah I am passing only hadle and pointer to RECT.
I found that handle from ID.But Problem is there,as I used this fnction so many
times It works fine.
|| ART OF LIVING ||
|
|
|
|
|
I can't imagine what the problem is. Maybe a bit of debugging on your end will help?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Why draw on the dialog? Why not draw in your own window that is a child of the dialog?
Of course while drawing on a dialog it's a good time to eat your Fish Filet
Actually I am not sure he needs to draw, maybe just use a static control and put some text in it, hard to say from his post. I think he really needs[^]
|
|
|
|
|
Yeah....you're just trying to drag me into this, huh?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Was it a joke or anything. No doubt my total VC experience and total experience is 1.5 years , and Basically I am Mechanical Engineer, but right now I am developing
FingurePrint Identification Server For ATM Parallel to Main Switch for Identification
Aplab India,
Near CheckNaka,
Thane(W),
Maharshtra
India -400604.
I am putting in joke to bypass from main discussion.
|| ART OF LIVING ||
|
|
|
|
|
I am not that master of VC ,but I have to work on very higher end.
I need to show somehow how many atms ,which all atms are currently running.
Doubt is lack of Life force , Answers cannot satify doubt Only Art Of Living Can Solve www.artofliving.org
|
|
|
|
|
shivditya wrote: It crashes at ::GetWindowRect Of groupbox in which I was planning to show the running threads.
"show the running threads" what does that mean? Show them how?
If you just want to display some text put a static control in side the GroupBox control and then SetWindowText on the static control.
|
|
|
|
|
No not like that.
Just like bar graph
I said Group Box Because ,I Just kept groupbox to have some border around
Graph. And I was taking its rect because I was willing to have some
Base coordinates.Which ATM is running ,graph line will be shown for it on y axis.
And ATMs will be on X axis.
|| ART OF LIVING ||
|
|
|
|
|
shivditya wrote: Just like bar graph
Ok then you definitely don't want to draw that on a dialog that has other controls on it. You want to make your own window and draw the graph in there then that window is placed on the dialog as a child like other controls are. If you are using MFC you just derive from CWnd then in the dialog you setup the window as a child using whats called "subclass"ing.
Have you looked at the C++ articles here on CodeProject. I would imagine there are some that walk you through all of this. There is probably even a article with code that will draw the bar graph for you.
|
|
|
|
|
Thanks I will Search for it.
Conclusion
1) Drawing on dialog is not so easy.
2) Subclassing will help // I dont
3) Can diretly add classes which are already developed.
Will you please redirect me to what exactly you mean by placing child window on dialog.
class CDerived : public CMyMainDialog
{
--------
};
CMyMainDialog cm = new CDerived()
cm.Domodal();
|| ART OF LIVING ||
|
|
|
|
|
shivditya wrote: Will you please redirect me to what exactly you mean by placing child window on dialog.
It's called subclassing and you should find tons of articles here on CodeProject in the C++ and/or MFC categories that will help in this subject.
|
|
|
|
|
shivditya wrote: Conclusion
1) Drawing on dialog is not so easy.
2) Subclassing will help // I dont
3) Can diretly add classes which are already developed.
1) Drawing on a dialog is just as easy as drawing on any window. It's just not a good solution
beyond maybe drawing a custom background.
2) You're using MFC - the subclassing is done for you if you use CWnd as a base class.
shivditya wrote: what exactly you mean by placing child window on dialog.
Every control on your dialog is already a child window of the dialog. It seems logical, then, if
you need an area of the dialog to draw in then you should use a child window to do so.
You can place your child window on the dialog just like you'd use a child window anywhere -
1) Implement the window class, or use an existing window class, perhaps 3rd-party code
2) Create a child window object of that class
3) Create the Windows object (HWND) for the window object, using the dialog window as the parent
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I got now by looking in article the subclassing means customising.
And I have done it many times,without knowing that term.
Ok I will try out ,based on time in hand.
|| ART OF LIVING ||
|
|
|
|
|
Hi everybody. I'm developing an IC card handset device application with standard C language.I'm a new comer to C language.I have a question
Look at the funtion definition :
<br />
unsigned short dt_recv(unsigned char *data, int *datalen)<br />
Input parameters: <br />
Data : to receive data buffer<br />
Output parameters: Datalen:receive data buffer size<br />
Return values: none.<br />
<br />
Communication Protocol :<br />
data[0]=command head; <br />
...<br />
data[3]=high of length; <br />
data[4]=low of length;<br />
...<br />
Data[3] and Data[4] store a Int16 value.I have problem when I try to get the value.Here is my code:
<br />
short i;<br />
memcpy(&Data[3],&i,2);<br />
But it seems that I did not get the right value.I guess I'm in the wrong way.I'm not familiar with memory operation.
Can any one give me the right way?Any idea will be appropriate.
|
|
|
|
|
are you a chinese boy?
|
|
|
|
|
My suggestion (not tested):
short i;
i = (short) ((data[3] << 8) | data[4]);
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Xiaoming Qian wrote: short i;
memcpy(&Data[3],&i,2);
But it seems that I did not get the right value.I guess I'm in the wrong way.I'm
Are you wanting the value of Data[3] or i ? The signature for memcpy() is:
void *memcpy( void *dest, const void *src, size_t count ); So what you have is writing from i to Data[3] .
"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
|
|
|
|
|
Xiaoming Qian wrote: short i;
memcpy(&Data[3],&i,2);
On Intel machines, i is stored with the least-significant byte first. If you use memcpy like
this then
Data[3] == least-significant byte of i
Data[4] == most-significant byte of i
To get the value back. something like:
short i = (short)((unsigned short)Data[4] << 8) | (unsigned short)Data[3];
or
short i;
memcpy(&i,&Data[3],2);
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Here "data[]" is an array. so "data" itself an a address.
And instead of using "&Data[3]" use "Data[3]" in "memcpy" function
That is:
short i;
memcpy(Data[3],&i,2);
|
|
|
|
|
Wrong. The first argument to memcpy() needs to be an address, of which Data[3] is not.
"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
|
|
|
|