|
1. What do you mean by visible rectangle? If you mean the client rect of your window, you already queried that here:
Abhinay Kumar wrote: GetClientRect(hWnd, &rt);
But note that in your code sniplet you get the client rect of the window into your rt variable and then you never use it, you explicitly define another rectangle called rtClient here:
Abhinay Kumar wrote: SetRect(&rtClient,10,10,50,40);
and then use that to draw the text. Shouldn't you either be uring rt instead of rtClient to draw OR use rtClient in GetClientRect?
2. What should FORWARD_WM_CTLCOLOR do in the first place?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Here i am giving it manual values but what if i want to draw a rectangle within the parent window.Therefore in GetClientRect(hWnd,&rt), i m geeting the coordrintes of parent window and then want to set the coordinates of the rectangle that i want within this window using SetRect(&rtClient,rt.left,rt.top,rt.right,rt.bottom); and display it using ExtTextOut().By Visible i mean
i am not able to see the rectangle within the window.Please reply.
|
|
|
|
|
I'm not quite sure what you mean, do you mean you want to know where a control is positioned in its parent's client area? If so, do something like this:
RECT controlRt;
::GetWindowRect(controlHWnd, &controlRt);
::ScreenToClient(parentHWnd, &controlRt);
Also note that to draw into the parent's client you need the parent's client DC, is that what you are using? If you did something like putting your drawing code inside the WM_PAINT of some control on that parent, did BeginPaint() and then you want to draw to the parent using the DC you got back, that won't work since the DC you get from BeginPaint will be "referring" to (and be clipped to) the client area of the window that got the WM_PAINT, not its parent.
If this is not what you meant, try to explain a bit more clearer what you need, please.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Please get it in simple terms that i want to draw a rectangle within the hello world window that should uses GetRect(),SetRect() and ExtTextOut().Is it possible?
|
|
|
|
|
Well, telling from this much information, it seems to be possible. Is this some school project?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Yes.Plz,plz tell me or if possible give me the code to do it in visual studio6.0
|
|
|
|
|
Well, first of all, the forum here isn't for doing other people's homeworks, if you can't do it yourself you are most likely have chosen the wrong thing to study. We will help if we can, but don't expect other people here to do your homework for you.
Anyways, do you have to do it using MFC or only API calls?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
|
Do you have the window already showing and all, you only need the drawing code? If so, write a handler for the WM_PAINT message and in this message do the following:
PAINTSTRUCT PStruct;
HDC dc = BeginPaint(handle_to_wour_window, &PStruct);
RECT Rt;
GetClientRect(handle_to_wour_window, &Rt);
TextOut(dc, Rt.left, Rt.top, "Hello", -1);
EndPaint(handle_to_wour_window, &PStruct);
Try to get this to work.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
|
Abhinay Kumar wrote: Can i get a visible rectangle...I tried it but am not getting the rectangle.
Maybe because you do not have any code to draw the rectangle. Why are you not calling Rectangle() ?
Why not try something like:
TextOut(ps.hdc, rt.left, rt.top, "RAM", 3);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
bcoz i dont want to.I want to use GetRect()to get the parents rect structure and using SetRect()set the childs rectangle coordinates.and ExtTextOut()to view it.can it be done?how?
|
|
|
|
|
hi experts I have one problem in my project.initially it is giving output properly.but if i debug the application it is giving some error messages.after that it does not executing properly.if i restart the application it is working properly.please let me know the reason?
kir_MFC
|
|
|
|
|
kir_MFC wrote: but if i debug the application
You mean running in debug mode or just stepping through every line? Are you sure you are running the same version (debug/release) on both the occasions?
|
|
|
|
|
With out knowing what error is happening, how one can help you?
Please tell more details about the error message.
- ns ami -
|
|
|
|
|
kir_MFC wrote: ...it is giving some error messages.
Is this supposed to be helpful?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hello Everyone there,
I am working on vc++6. An win32 console based application. I have this problem in my project...
Whenever I run my application the control comes to the function strcpy and stops and one dialog box appear by title "find source " and asking..."please enter the path for STRCAT.ASM." and a list of directories...
The strange behavior is that when I run the same code in a different win32 project, it runs perfectly....May be some setting...could u please help me out
code is....
char currentTime[20];
struct tm * pLocalTime;
strcpy(currentTime, ""); //error comes here
long int nLocalTime = 0;
time(&nLocalTime);
pLocalTime = localtime(&nLocalTime);
sprintf(currentTime,
"%04d-%02d-%02d-%02d.%02d.%02d",
(pLocalTime->tm_year) + 1900,
pLocalTime->tm_mon + 1,
pLocalTime->tm_mday,
pLocalTime->tm_hour,
pLocalTime->tm_min,
pLocalTime->tm_sec);
Thanks in advance,
Himangshu
I am a learner Always
|
|
|
|
|
Are you trying to debug? Got breakpoint in that line? What command are you using to run the exe from the IDE?
|
|
|
|
|
thanks smith...
I got that problem out....Donno I was using a char pointer before...Now I changed it to array...strange but its working now....
I was debugging it by pressing f5 and by putting a break point
Thanks anyway
I am a learner Always
|
|
|
|
|
I have a task where I am supposed to display the data(Clientname, id , year, license) on a list control from an XML file however when a new data is appended to the XML file with the same Clientname. I want the latest (i.e. recently appended data)should display.
Please let me know which function is required to perform this???
Thanks in advance.
modified on Wednesday, February 4, 2009 3:00 AM
|
|
|
|
|
- Detecting a change to a file - you want to use directory change notifications[^].
- Displaying the last item in a list in an XML file? Kind of depends on the schema of the XML file, but you could use XPath to find the last item, or iterate through the file - there are a lot of techniques - I'd advise you to work out how to use the XML library you're using to do this.
|
|
|
|
|
//Works
<br />
int py[5] = {0,1,2,3,4};<br />
int* pyp = (int*)py;
printf("%d",pyp[2]);<br />
<br />
//Doesn't.
<br />
show "2Dpointer\n";<br />
int py2[2][2] = {0,1,2,3};<br />
int **pyp2 = (int**)py2;<br />
<br />
printf("py2:%d",py2);<br />
printf("pyp2:%d",pyp2);<br />
<br />
printf("**pyp2[0][0]",pyp2[0][0]);
printf("**pyp2%d",**pyp2);
<code><br />
<br />
why? <br />
<br />
<div class="ForumSig">:beer:</div>
|
|
|
|
|
All index [] notation is converted to pointer arithmetic.
So, you declare
int py2[2][2];
the compiler knows the total size (2*2 = 4) and how wide each row is (2).
So if you do
py2[1][0]
the compiler can convert to
py2 + (1*2) + 0
But then you do
int **pyp2 = py2;
Now you have created an alias and lost all information about the dimensions of the array.
So, when you try to do
pyp2[0][0]
the compiler can only get to
pyp2 + (0*?) + 0
it doesn't know what to fill in for ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
but why does it work here ?
<br />
int py[5] = {0,1,2,3,4};<br />
int* pyp = (int*)py;
printf("%d",pyp[2]);<br />
As it shows, the memory has been laid out for these values,
[START_ADDRESS]4bytes,4bytes,4bytes,4bytes,4bytes.
So when you assign the pointer, it starts to point to the first item. Further when you make a pyp++ or pyp[], it's landing up on the right element. Here too, I'm not passing it any information about the size of the array. It's just the pointer and it's taking it up.
2D arrays, it's not too different from 1D. The next batch of numbers would be following.. err.. err. Okay as I'm typing this I'm getting it ..I'm not giving it any clue where the first row ends.. well..is that what you mean? sounds convincing but why not it work atleast for the first item? I'm just saying **pyp2. Just trying to get the value of the element it's currently pointing to. Why even this doesn't work?
btw, why the complier is not warning me about a meaningless assignment?
|
|
|
|
|
py2 is an address.
The contents of py2 are 0, 1, 2, 3.
Agreed ?
pyp2 is a pointer to a pointer.
pyp2 is initialized with the address of py2.
Now when you say *pyp2 it is taking the first value of 0 which it thinks is another address.
So, **pyp2 is trying to read the value at address 0. // Crash
If the contents of py2 were 5, 6, 7, 8,
**pyp2 will be trying to read the value at address 5. // Still Crash.
«_Superman_»
|
|
|
|
|