Method of getting text on a windows form ( unmanaged C++ project ) - c++

I'm in the process of learning C++. I've created a boilerplate Win32 app within VC++ 2008. I've studied through the code and am ready do do a bit of experimenting. I thought it would be cool to print all the windows messages received in the message loop to the form created via the boilerplate code. I for the life of me, can't figure out the method of getting text onto that form. I can't seem to identify and named object that I can use to reference that damn form. The best I can figure is I need to use the handle to reference the form somehow. Still, even if I did know how to reference the form, I'm not sure I know how I would create a label to display the text. Anyway, if someone could just point out what methodology I need to learn to make this happen it would be much appreciated.
Thanks,
Donovan

If you've created a label using resources, use its resource ID and
HWND *pWnd = ::GetDlgItem(mainDialogHwnd, IDC_YOUR_RESOURCE_ID);
::SetWindowText(pWnd, "Your Updated Text");
There are MFC equivalents for those too, should get you in the right direction. Note that posting message loop means lots and lots of information... might not want to do that. Check Spy++ if that's still available and in use today to see how many messages an app gets!

Related

Automatically filling a form and running a program

A friend sent me 3 programs, which are written in C or C++. Every program has a form, which is filled and then a button is pressed to perform some calculation. The programs were written in LabWindows/CVI which I've never heard of. He asked me, if it was possible to automatically fill the forms and run the calculation to get the output. I said that one way would be, to modify the program to a console one and run it with parameters (if the number of fields is low).
Does there exist a tool, which could be used to automate the execution of such programs or, if possible, does the LabWindows/CVI have anything which could help me, besides modifying the source?
I thank you in advance for you help.
you could use some automated test programs such as http://www.sikuli.org (this is written in java), it is also nice because you can add any java code you want to improve the test and modify it if you really need something extraordinary.
another way would be creating your own "automated test program" using c++ (since you posted this with c++ tag) to create a mouse and keyboard hook that will move the mouse and type characters on your forms.
the following links might help if you want to create your hooks C++ mouse click on certain spot in window, Global keyboard hook with WH_KEYBOARD_LL and keybd_event (windows)

Block alt+shift event or disable changing language in programming way

I need to block alt+shift keys event using C++, or some way to block changing language.
Thanks in advance.
I would go about it a bit differently. I would catch current langauge settings at startup than change it for desired one.
At the even of alt+shift i would just set it back to the desired type again.
It should be fairy easy to do with net framework.
Here is a short article about manipulating languages: How to change input language programmatically
And main class on msdna: InputLanguage documentation
To actually prevent alt+shift from moving into windows system you would have to play with hooks.
Here is an article about blocking keystrokes before windows process them.
Just an idea. You can catch WM_KEYDOWN message and call ActivateKeyboardLayout to switch language.
Using C++ you can install a keyboard hook procedure like the one suggested here and filter (swallow/don't propagate) the key(s) you want to forbid.
My understanding of MSDN is that you can pretend to process WM_INPUTLANGCHANGEREQUEST and then do nothing, so that Windows will not do anything further and the language will not actually change. But some users say that doesn't work any more.
http://msdn.microsoft.com/en-us/library/ms632630(VS.85).aspx
Maybe you can implement ITfInputProcessorProfileActivationSink::OnActivated, and when you get called you can change back to the previous language by calling ITfInputProcessorProfiles::ActivateLanguageProfile. At the beginning of your app you would call ITfInputProcessorProfiles::GetActiveLanguageProfile.
Maybe you can implement ITfLanguageProfileNotifySink::OnLanguageChange, set *pfAccept
to FALSE and return S_OK.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms628770(v=vs.85).aspx
All of the above have a problem. If the user intentionally changes languages on the client, for example by clicking on the client's task bar instead of pressing Alt+Shift, the above methods will prevent their change anyway.
I wonder if RegisterHotKey would let you register Alt+Shift for your own window even though the system already had it defined.
The thing you are trying to implement is keyboard hook. The detailed explanation with source code in C/C++ can be found here:
http://www.codeproject.com/Articles/67091/Mouse-and-KeyBoard-Hooking-utility-with-VC
Also other helpful examples can be found here:
http://www.codeproject.com/Articles/1264/KeyBoard-Hooks
http://www.codeproject.com/Articles/9513/Disable-keyboard-and-show-images-for-the-children
Hope this helps.
Kind regards,
Bo

How do I get a `callFrameID` to pass to `Debugger.evaluateOnCallFrame`?

WebKit's Remote Debugging Protocol went 1.0 recently and I've been playing around with it a little, mostly out of curiosity and interest. I've thrown together a very basic recreation of Chrome's developer tools console as a replacement front-end, but I'm a little confused as to how I can execute code in a specific frame/window like Chrome's Dev Tools allow you to.
At the moment, I'm using the Runtime.evaluate method to execute my console input. This seems inadequate because of the aforementioned problem and it doesn't provide the command line API. I've discovered the Debugger.evaluateOnCallFrame method, which requires a callFrameID parameter. The only problem is, it doesn't seem possible to remotely acquire a list of callFrame objects to pass to this method.
I have a feeling I'm completely missing something here. Does anyone know the solution?
Have a look at the Debugger.paused event, which will give you an array of current call frames.

how do I get win32 file browser with SDL?

I want to create an editor in C++ using SDL & OpenGL and have decided to use the win32 api to access the window bar menus (for file, edit and so on) and it seems quite simple, but I don't know how to create a "file-> open" file browser/loader... I'm hoping it's quite simple but I'm finding it hard to look up any tutorials on google because of the phrasing...
I just want to have an "open" or "import" option in the file menu that will open a standard windows file browser... then grab the file location, place it into a string then pass it into a function that is activated by selection a file... (I hope that makes sense).
The method I'm using to create the win32 menus are from this post:
http://www.gamedev.net/topic/400677-sdl-with-a-win32-menu/
Half way down the page there is a comment by "caseyd"... that's how I learnt how to use it, so that is my current understanding of win32 menus in SDL... I wanted to post the code here, but I didn't know how to paste it here in codeblocks without reformatting every line.
I'm hoping this is quite simple... Thanks to anyone who can teach me how or just point me in the right direction.
Oh, and I'm not trying to convert this to other operating systems, I just like SDL.
Use GetOpenFileName(). Note that that function blocks until the user selects a file, so if you want to continue rendering etc. in the background, make sure to run it on a separate thread.

Parse information from programs added to taskbar with C++

Basically what I am trying to do is write my own pseudo task bar in C++. The program needs to idle until another program is started up, at which point it needs to visually depict that the other program is running. For each other program that is running, the user should be able to click on the visual representation and have Windows switch focus to the selected program.
The big underlying question at this point: is this even a possibility? Or has Windows hidden most/all of its fiddly-bits to make this close to, if not completely, impossible?
[EDIT:] restructured the question
The obvious starting point would be SetWindowsHookEx(WH_SHELL,...); which will get you notifications when top-level windows are created or destroyed (along with some other related events, like a different window being activated, a window's title changing, etc.)
Think ahead to actually bringing the window to the front, as I once researched myself.
SetForegroundWindow() won't work unless issued from the foreground process - neither SwitchToThisWindow() nor the AttachThreadInput() kludge seemed to always work, but maybe I just wasn't doing it right. Anyway as far as I know there no way to make a window foreground as good as Windows does, please enlighten me if say you discover say an undocumented call which actually Works.
It seems possible to me at least in a basic way:
1. Set up a shell hook as described by Jerry
2. figure the executable file from the module handle to access it's icons using shell services
The Vista-like feature of keeping a 'live' miniature of the screen seems much more challenging.