|
|
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.
|
|
|
|
|
Hi,
Could you please elaborate the question?
Are you looking for the Sector information of the Physical drives i.e Hard disk or USB disk??
|
|
|
|
|
I want to get the disk size for every physical disk. The CHS parameter is true for harddisk,but wrong for USB flash disk. Becase the system assume that's X*255*63,the total sectors are also wrong. I dont know what function can I use.
|
|
|
|
|
Hi As per my knowledge, You can open any disk (using CreateFile(DriveName,....)and after reading the first sector of the disk you will get Boot record of the same from there I feel you can get the size of the disk
Otherwise harddisk has Master boot table from where you can get the partitions and their sizes.If you want to open a physical drive you can open it using the CreateFile("\\\\.\\PHYSICALDRIVE0",....) for the harddisk.and after reading the MBT you can get the drive information .If you want to use the WINDOWS api then you can use GetDiskFreeSpace() API and pass NULL as a root directory it will return you the TOTAL number of clusters,multiply it with the Sectores per cluster and bytes per sector.You will get the disk size.
|
|
|
|