|
You can create controls using CreateWindowEx
Do not use stuff like CButton and CWnd. Those are MFC classes.
For a button call CreateWindowEx and use "Button" as the lpClassName parameter
Nish
Chris,
Can I have a Johnny Bravo icon please?
Please, please, please........
|
|
|
|
|
Thank you very much Nish.
nay
|
|
|
|
|
|
Hi,
I found some translation software can extract string
from where the mouse points to and translate the word
on the fly. I was wondering how can this be done and
is there any Win32 API can archieve this function. A
brief explanation will be appreciate
Thank you very much
Angus Liu
|
|
|
|
|
This SO needs to make the FAQ, I know I've answered it 15 times.
The two ways to do this are using WindowFromPoint and GetWindowTest ( advantages: can find text that is obscured, disadvantages, will not work with text in bitmaps, is complex in other ways ( what word am I over in a sentence, etc. )). Second, write some OCR software. Advantages - works with everything, disadvantages - you have to write some OCR software.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Hi Christian,
Thank you for your quick response.
I've not been awared that I'm asking a common question
like this. But I'm a causal visitor of this site and
didn't roll back to find out where your other 14 answers
appear. Anyway, Thanks a lot for your 15th answer
Angus Liu
|
|
|
|
|
That's cool - it's not that I'd expect you to read the rest of the site, only that it would make a good inclusion to the FAQ ( which I would hope people read ), because it is asked so often.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
|
Thanks! I read that However, I still think there is a
way out other than using the OCR technique...
I got an English-Chinese translation software here called
Dreye 2002. Well, the name of the program isn't important.
It does the trick of extracting the word in the sentence
from where your mouse's pointed at. I don't think it involves
OCR because it can't read text in the bitmap. Another reason
is that recognition of Chinese character is so complicated that
can't be always 100% correct. But this program can read chinese
character with no errors and translate it into English on the
fly, and vice versa. It looks to me that it can read any piece
of text drawn by Windows, including text in RichEdit control,
WebBrowser Control, Menu, Title Bar of a window, etc. virtually
every piece of text so long as it is not in bitmap format.
I've looked up in MSDN for the solution. My attempt wasn't very
successful. That's why I come up with this question
Anyway, it's so nice to have so many experts around and tries to
answer my question. Thank you all!
Angus Liu
|
|
|
|
|
Just an addition to CG:s answer:
GetWindowText will not work on passwords on some versions of Windows (NT+ ?) if used from outside process. Use dll-injection to get your code inside the process...
GetWindowText will not work in a WebBrowserCtrl. Use elementFromPoint/get_innerText in this case...
/moliate
|
|
|
|
|
Cool - my answer is designed to show how big a task it is ( and therefore beyond the scope of some thing that could be answered here in one go ). You've made me realise it's even worse than I thought. I guess OCR is the only viable option.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Cheers, Moliate.
You explained my worries about retrieving a string from
WebBrowser Control. But doesn't getting innerText return
all text that an element has? Say, I have a piece of text
"Hello! World" inside a pair of tag. And, my mouse
is hovering over the word "World". Any more specified
function can return the word "World" instead of "Hello!
World"? Or, even more fussy, tells me my mouse is over the
character 'W'.?
Well, Sorry about my nagging questions:P
Angus Liu
|
|
|
|
|
ykliu wrote:
But doesn't getting innerText return
all text that an element has?
Unfortionally, it does.... (similar to GetWindowText)
I really don't know how to get a specific word or character. A possible (but probably not the best) solution would be to make a copy of the element and gradually update the text so it removes one word after another. At the same time reduce the mouse coordinates by the difference between the original elements lower right corner, and the copys lower right. When the mouse goes out of the bounding box, you have the word pointed at... (hopefully)
/moliate
|
|
|
|
|
That's all right, your explanation has been very
helpful. I really appreciate it
Angus Liu
|
|
|
|
|
Dear Friends
I made one c file in which i am reading an input .bmp file and after certain modification i am writting it in an output .bmp file.
But due to plain C code response is not proper. So want to display output file by getting CDC/HDC so i can see the output directly just after build.
What i have to do.
I am new to VC++. Will anyone please give me a complete project file details from which i can understand it and do certain modification. time is less and so need it urgently. Please Help me.
Thanking you in advance.
Vinay
|
|
|
|
|
Use ::LoadImage to load the file you've just written from disk, then select it into a HDC. Use GetDC(NULL) to get the DC of the screen and you can BitBlt your new bitmap direct to the screen.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
u mean to say by LoadImage i can directly load the my previously built .cpp or input bitmap file. Will you please give me some example code for doing this. It will be agreat help to me.
Thanking you in advance
Binay
|
|
|
|
|
jas - I need to load up the msdn. It's msdn.microsoft.com for your future reference.
HBITMAP MyBitmap = ::LoadImage(
MyhInst, // Assuming you're not using MFC, you'll need to store your instance handle and put it in here, or try NULL
"c:\mybitmap.bmp", // I presume you have this in a variable already....
IMAGE_BITMAP,
0, // These can be set to the x and y values desired if you wish.
0,
LR_CREATEDIBSECTION | LR_LOADFROMFILE);
this will load the bitmap file from disk into a HBITMAP. Now you can create a DC, select it in, and draw it onto the screen.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Is there a way to set a windows parent window other than using SetParent?
What I want is for the child window to not be clipped inside the parent window, just appear on top of it all the time, and minimise with it etc.
Is it another call I have to make after SetParent?
Thanks in advance.
--
David Wengier
TAC ad gone wrong: "Don't fool yourself, you're a bloody idiot."
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
David Wengier wrote:
What I want is for the child window to not be clipped inside the parent window, just appear on top of it all the time, and minimise with it etc.
Normally it is clipped only if it is an MDI child window.
Is that what you mean?
Nish
Chris,
Can I have a Johnny Bravo icon please?
Please, please, please........
|
|
|
|
|
It appears exactly as you would expect if it was an MDI child window, but its not, and the parent isnt an MDI window!
I was just thinking though, and I was wondering if it might actually be something in the creation of the child, rather than the showing of it. Like maybe it needs a taskbar button to appear outside the main window.
--
David Wengier
TAC ad gone wrong: "Don't fool yourself, you're a bloody idiot."
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Parent->child relationship always imposes clipping. There's also owner->owned relationship, but AFAIR, you can't change that after creation. For example, dialogs are usually owned by main window.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Tomasz Sowinski wrote:
also owner->owned relationship
That sounds exactly like what I want.
Tomasz Sowinski wrote:
but AFAIR, you can't change that after creation
Thanks for the help
--
David Wengier
TAC ad gone wrong: "Don't fool yourself, you're a bloody idiot."
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Hi,
I have just recently started a project in MFC/Visual C++. As far as my windows programming experience goes I have done a bit of plain C, as well as a lot of Visual Basic. I'm not having too much trouble grasping the C++ language, but what I do have trouble understanding is MFC and how I extend upon it. For example the app I am developing just has a dialog box, and I want to write code to execute when the user presses the minimise button on the dialog box. I believe this can be done through CMyAppDlg::OnPaint with a check of IsIconic, but where do I find out other things like this? Is there a proper MFC reference that explains things in simpler terms and what they canbe used for? I'm just getting a bit lost, it was a lot easier when each dialog box or window I created in C had its own message loop.
Kind Regards,
Ross Cousens
|
|
|
|
|
You can emulate this by catching the message before MFC gets to it, but the short answer is use the msdn. msdn.microsoft.com if you don't have it on your PC.
And ask here, of course.
By the way, I believe it's better to catch the minimize action somewhere other than OnPaint, I believe there is a message when the window state is changing, I'd go for that.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|