|
|
I assume that you are having a dialog based app with MFC support.
In the dialog, you are having a static rectangle (picture control) with SS_NOTIFY style (Notify can be selected in the Properties > Styles of picture control) named IDC_PIC.
You need to derive a class of CStatic. In that you can code for mouse events. Create a control variable of your IDC_PIC with this new class.
Hope now you can continue...
- ns ami -
|
|
|
|
|
1.Can i get a visible rectangle in a simple(typical win32)application?I wrote the code in WM_PAINT message as given below?I tried it but am not getting the
rectangle.Can any one help me in this?my code in WM_PAINT is
RECT rt,rtclient;
GetClientRect(hWnd, &rt);
SetRect(&rtClient,10,10,50,40);
wsprintf(buffer,"%d %d %d %d",rtClient.left,rtClient.top,rtClient.right,rtClient.bottom);
SetTextAlign(ps.hdc,TA_CENTER | TA_TOP);
ExtTextOut(ps.hdc,15,20,0,&rtClient,"RAM",3,NULL);
2.FORWARD_WM_CTLCOLOR()is not recognized in visual studio6.0.Is there any alternative function which does the same job?
|
|
|
|
|
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>
|
|
|
|
|