|
I have an application that draws a diagram in the form of a bitmap and then displays this in a window. There are limits placed in my code that do not allow
the CSize properties cx and cy to be set to more than 32000 in 'SetViewportExt' and 'SetWindowExt'. This limits my the amount of my diagram that i can draw, and believe it or not someone has managed to make a diagram that exceeds that would exceed the cy component of this diagram. I took these limits out in order to be able to display the whole diagram and it worked well, the CSize objects passed to the 'SetWindowExt' and 'SetViewportExt' methods had cy components that exceed 32000, in fact they were in the region of 69000. However when i doubled the size of my diagram, which is draw as a bit map, it failed. Let us be clear the parameter is was now setting the CSize object to that would be passed to the two previously mentioned methods, were 140000 (cy component) and 2000 (cx) component. The failure was that i had lines running over the top of my diagram, i spoke to someone who was previously involved this project and they told me without those limits, i was "killing the DC", sadly he couldnt tell me, anymore, it seems that there is some sort of limit?
Can anyone help me with understanding this, or perhaps offer a solution
Many thanks
Will
|
|
|
|
|
hi,
Can you tell me what is the Diff between CFile and CStdioFile. when to use each of these.
Thanks.
|
|
|
|
|
karmendra_js wrote:
Can you tell me what is the Diff between CFile and CStdioFile. when to use each of these.
CStdioFile is derived class on CFile.. so all CStdioFile has all capibility that CFile have plus It's special file reading Function like ReadString():- which read one line at a time etc.
karmendra_js wrote:
when to use each of these.
CStdioFile is benificial when you are using it with text based file.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
|
How can we get the capture text from any part of ui. E.g. in case if we have window that has some third party child control, now I want to extract the text from that control, OR in I.E. there is an applet and that applet is containing text, I want to extract text out of that applet. I do not want to use any specific library of applet or for that matter third party control. I believe, we need to first get image of that window(bmp), but then from that bmp how to convert in editable text?
|
|
|
|
|
If we're talking about windows that are actually textual windows such as edit boxes and similar, you can use ::ChildWindowFromPoint and/or ::WindowFromPoint and ::GetWindowText.
Otherwise I suggest you get yourself a nice OCR-library that recognizes the characters in the bitmap you caught.
Hope this helps
--
Roger
|
|
|
|
|
My aim is to repeatedly call a function, display the return values in an edit box, when i press a button. This should stop when i press another function.
I kept the function call and the display in an while loop which checks for the condition if the 2nd button has been pressed.
But it didnt work. The application hung. Maybe bcos the while loop never ended.
How will i go about it?
Say the function tat i want to call repeatedly is CalculateVolts() and UpdateData(FALSE) is used to update the edit box.
This is what i did.
<br />
OnButton1(){<br />
while(flag_button2!=1){ int retVal = CalculateVolts();<br />
m_editVal.Format("%f",f); UpdateData(FALSE);<br />
}<br />
}<br />
<br />
But since the application hung i cud never press Button2.<br />
|
|
|
|
|
1) You need to start a worker thread and in that the while(button2) should be waiting
2) Now in handler of Button2 , use CCriticalSection to set the value to button2 = 1
Your code did not work becasue
1) it is not multithreaded
2) as you said the control never went out of while() loop
redindian
|
|
|
|
|
1. Or the simpler way is just put sleep after UpdateData(FALSE)
Sleep(1000)
|
|
|
|
|
Sleep also locks exicution. If you have another thread it will allow that thread to run but it won't allow for what he is looking for.
a programmer traped in a thugs body
|
|
|
|
|
Hello,
Your control handler never leaves execution. This means that no message gets processed after you press button1.
You can solve this problem by posting a message to your own window after the call to UpdateData() .
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
In OnButton1, create a timer (i.e. SetTimer) with a delay of 1 millisecond. Let OnButton1 return. Inside the OnTimer method, update the edit control. Do not kill the timer. Inside of OnButton2, add a call to KillTimer to stop the timer.
This is very simple method of doing what you ask without having to create new threads or anything complicated. Since timer events are very low priority, the edit box will be allowed to update and the UI will continue to pump messages.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
If you kill the timer in the OnTimer method then start it again after the edit control is updated. This guarantees a 1msec delay between actions, otherwise you could get a queue of timer events in the time all the processing takes.
The tigress is here
|
|
|
|
|
thank you.
I used the timer idea and it actually worked
|
|
|
|
|
Trollslayer wrote:
otherwise you could get a queue of timer events
AFAIK WM_TIMER, like WM_PAINT, is a low priority and does not queue. A WM_TIMER message is only posted when the message queue is empty.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote:
WM_TIMER, like WM_PAINT, is a low priority and does not queue
This is correct. This is handled by the kernel and there will never be any WM_PAINT or WM_TIMER messages in the thread's message queue.
Regarding timers it's ridiculous even thinking that such a timer will have a period time of 1ms. Windows is not a real-time OS.
What will happen is that you will not get multiple WM_TIMER messages in the queue, BUT the WM_TIMER handler won't get called in the rate you expected.
You can simply verify this by the use of ::QueryPerformanceCounter and logging the rate that the handler is actually called.
Joe Newcomer wrote an excellent article about this and can be found at
http://www.flounder.com/time.htm[^]
--
Roger
|
|
|
|
|
thank you.
I used the timer idea and it actually worked
|
|
|
|
|
Hi all
I have a toolbar IDR_MAINFRAME with 8 Icons . During runtime, I want one of the buttons to be disabled or grayed .
I can see the usage of ON_UPDATE_COMMAND_UI here in mainfrm.cpp
ON_COMMAND(ID_FILE_PRINT, OnIDFilePrint)
ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint)
here OnIDFilePrint() is called when I click on the "Print" toolbar button .
But as I am new to usage of pCmdUI etc , I dont know how to disable the 6th button - print button in this toolbar .....
Anyone to help me ...?
I need to disable this toolbar button from outside the mainfrm.cpp ...
Any help pls ....
redindian
|
|
|
|
|
dharani wrote:
ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint)
For achieving same you have to have handller for each of toolbar button... and implement the coding for individual
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi alok
I did not get it ...
In fact in my code (9000 files) , I can see this print button disabled /enabled during runtime based on some inputs ...
But I am not able to find out the particular code which send a message to disable the print icon/button ....I have been searching for something stright like EnableWindow(0) ...and found the mechanism is very different ...
Any clues of diabling a toolbar button which uses this pCmdUI interface ?
redindian
|
|
|
|
|
dharani wrote:
Any clues of diabling a toolbar button which uses this pCmdUI interface ?
Could you show me current coding of OnUpdateFilePrint HANDLLER for On_update_Command_UI ..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I think any button can be disabled by getting a pointer to it and calling EnableWindow()
SkyWalker
|
|
|
|
|
dharani wrote:
But as I am new to usage of pCmdUI etc , I dont know how to disable the 6th button - print button in this toolbar .....
In the on_update handler for ID_FILE_PRINT , use:
void OnUpdateFilePrint( CCmdUI *pCmdUI )
{
pCmdUI->Enable(FALSE);
}
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
david crow has given u the correct answer...
tiru
|
|
|
|
|
The USB flash disk have no CHS parameters (the system use virtual parameters),I only need to get teh total sectors for physical drive. The MBR and BOOT may be failure. so your function is invalid. ,how to do it? Thanks.
|
|
|
|