Two Win32-DOS Console Programing Questions
To get things rolling, I''m using MSVC++ 6.0 with MS Dev Studio Pro. I''m working with a WIN32 Console Application.
1) Is there a way to Imbed an Icon into your .EXE file with a Console program? I can include the ICON as a Resource in MSVC, and that works, but it doesn''t seem to use it. Any ideas how to do this?
2) Is there a good way to pick up a single character keystroke from the keyboard and continue the program without having to type something and press ''enter''? I think GetAsynchKeyState is what I''m looking for, but I''m not sure how to format this in a Console App.
Thanks!
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
1.
i''d use a shortcut to display the icon.
program.exe <- a console-based program
program.ico <- the icon, on the same directory
and then when you make a shortcut to program.exe, the shortcut icon should be program.ico.
2.
Same thing. There''s no format difference between Win32 and Console (not DOS) application, as long as both of them support Win32 API.
My compiler generates one error message: "does not compile."
i''d use a shortcut to display the icon.
program.exe <- a console-based program
program.ico <- the icon, on the same directory
and then when you make a shortcut to program.exe, the shortcut icon should be program.ico.
2.
Same thing. There''s no format difference between Win32 and Console (not DOS) application, as long as both of them support Win32 API.
My compiler generates one error message: "does not compile."
My compiler generates one error message: "does not compile."
Getch() works great. Can''t believe i forgot about that. Never used kbhit() but it would probably work too.
As for the .ICO, I was hoping to have a way to embed it, but if not, then just using a Windows shortcut will have to work..
Any other suggestions on the .ICO? Is there a way to embed an ICO in a Win32 Console App?
Thanks!
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
As for the .ICO, I was hoping to have a way to embed it, but if not, then just using a Windows shortcut will have to work..
Any other suggestions on the .ICO? Is there a way to embed an ICO in a Win32 Console App?
Thanks!
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
Have you tried using a resource like you would with a regular Win32 app?
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
quote: Original post by siaspete
Have you tried using a resource like you would with a regular Win32 app?
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
It allows me to add the resource in just fine, but then it doesn''t automatically USE that icon on the .EXE - Any suggestions?
Thanks
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
How do you want to USE that icon? Explorer will use the first embedded icon to display the exe. You won''t get the console window to use your icon - at least not without some hacking.
What is it that you want your program to do with the icon?
What is it that you want your program to do with the icon?
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
quote: Original post by LessBread
How do you want to USE that icon? Explorer will use the first embedded icon to display the exe. You won''t get the console window to use your icon - at least not without some hacking.
What is it that you want your program to do with the icon?
I was wanting the Icon to simply be displayed on the .EXE in Windows. Explorer doesn''t seem to be picking up on the embedded ICO.
So maybe the Icon isn''t being included into the .EXE as I thought.
Here is what I''m doing..
I''m simply adding a Resource to the Project of type ICON. Saving that Icon as a file. It is listed in my files as part of the Project. However, I didn''t create a Resource Script, so maybe that''s my problem...
I''ll play with it and see what I can get to happen.
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
That was it.. I added a Resource Script file and imported the Icon, it''s working now. Thanks.
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
I just saw this in the microsoft.public.platformsdk.shell newsgroup. You might find it useful too.
Thank you! Works like a charm.>-----Original Message----->>Is it possible to make and display an icon for a console >>application?>>Yes it is Jaan. Here''s an example:>>#include "stdafx.h">#include <windows.h>>#include "resource.h">#include <conio.h>>>int main(int argc, char* argv[])>{> HWND hFocus = GetForegroundWindow();>> if ( hFocus != NULL )> {> HICON ico = LoadIcon( GetModuleHandle( NULL ),> MAKEINTRESOURCE( IDI_ICON1 ) );>> if ( ico != NULL )> {> SendMessage( hFocus, WM_SETICON,> ICON_BIG, (LPARAM) ico );> SendMessage( hFocus, WM_SETICON,> ICON_SMALL, (LPARAM) ico );> }> }>> printf("Hello World!\n");> char ch = getch();> printf("Goodbye cruel world\n" );> return 0;>}>>Dave>-- >MVP VC++ FAQ: http://www.mvps.org/vcfaq>My address is altered to discourage junk mail.>Please post responses to the newsgroup thread,>there''s no need for follow-up email copies.>.>
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement