|
Hi,
I have written an app that controls another application - it basically packs its files, allows customisation of its window title and icon, adds an alternative splash screen and various other features specific to the app. The application my app controls is third-party, so I have no access to its code.
Everything is working fine, but I was wondering if there is a better way of changing the icon and window name at run-time than the methods I am currently using.
(Incidentally, I am using the straight Windows API with _no_ MFC.)
To change the window title, I have written this loop:
<br />
while(thirdParty_hWnd == 0)
{<br />
if(WaitForSingleObject(thirdPartyApp.hProcess,0)==WAIT_TIMEOUT)<br />
{ <br />
thirdParty_hWnd = FindWindow("thirdpartyappclass_mainwin",NULL);<br />
<br />
SetWindowText(thirdParty_hWnd, "New Win Title");
<br />
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))<br />
{<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
}<br />
else<br />
{break;}
}<br />
The problem here is that the window title of the third party app does not appear in the window immediately, so my code sets the title before the app does. This means that the title is changed back a second or less after this code has been executed, meaning that I have to check the window title again in my next loop and change it back if necessary, like this:
<br />
char title_str[MAX_PATH];<br />
<br />
while(thirdParty_hWnd!=0)<br />
{<br />
if(WaitForSingleObject(thirdPartyApp.hProcess,0)==WAIT_TIMEOUT)<br />
{<br />
GetWindowText(thirdParty_hWnd,title_str,MAX_PATH);<br />
if(strcmp(title_str,"New Win Title")!=0)<br />
{<br />
SetWindowText(thirdParty_hWnd,"New Win Title);<br />
}<br />
<br />
//message loop here<br />
}<br />
}<br />
Although this works, the main problem is that this means the window title is set to what I want ("New Win Title" in the example) at first, then it reverts to the default app title briefly before getting changed back to, for instance, "New Win Title". Does anybody know of a better way of doing this, so that the original app title would never show at all? (Also, please bear in mind that I a relative novice, so feel free to tell me where my code is shoddy and suggest improvements.)
To change the icon, I use the following code:
<br />
SendMessage(thirdParty_hWnd, WM_SETICON,(WPARAM)ICON_BIG, (LPARAM)(HICON)NewIconBig);<br />
SendMessage(thirdParty_hWnd, WM_SETICON,(WPARAM)ICON_SMALL, (LPARAM)(HICON)NewIconSmall);<br />
(where NewIconBig and NewIconSmall are HICONs that point to an .ico file.
The only problem is that for this to work, the above code has to be contained in a while() loop (otherwise the icon is lost when you alt-tab etc). Although this works fine, looks good, and I have not noticed any slowdown, I am aware that this is probably not good practice to have a message sent to another window constantly. Is there anyway I can change the icon without having to continually tell the other window? (Note that in this case I cannot use an icon changer as the third party app has a built in checker that will cause the program to crash if any of its resources are changed.)
Any suggestions for improvements to my current methods would be much appreciated.
Many thanks,
KB
|
|
|
|
|
Hi,
I have been successful in getting tool tips to work with modeless dialogs.
I have a dialog with one button on it. I have attached tool tips to both the dialog and the button. When I put the mouse over the dialog, the tool tip comes and stays for a while as in standard windows.
However, when I put the mouse over the button, the tool tip comes up and quickly disappears. How can I make the tool tip for the button behave the same way as the dialog?
Thanks.
Martin
|
|
|
|
|
I guys
i have a question
can anyone point me to a piece of code that verifys if a mail is valid??
i have a mail list and i have to verify if the emails still exist.
I know that i have to connect to the mx server and ask to login, is the mail exist the server asks the password, if the mail dont exist the server fires a error
but i fellbehind on schedule and it wound be great if someone poit me to a working piece of code
thanks
MSN:maxsnts@hotmail.com
|
|
|
|
|
Hi!
I have InstallShield for Visual C++ 6.0 and today is the first time I have tried to use it.
Quickly I had my executable in an installable format but it also needs some DLLs I have written. I create a file group called "Libraries" and put my DLLs in it and then mark the file type as containing all self-registering files.
So I have now two file groups:
1. Program Executables
2. Libraries
I build my project and install it. Everything in "Program Executables" is copied to my directory but "Libraries" are ignored. How do I get InstallShield to install my DLLs and register them?
Also can anyone tell me how to tell InstallShield to create some registry entries.
Last, does anyone know a quick tutorial?
Thanks to all!
|
|
|
|
|
Hi!
I have Installshield for VC++ 6.0.
|
|
|
|
|
I am new to the field of VC++....can anyone please tell me as how to create a program that reads a text file, line by line....and if possible how to read each line starting from a particular character to a specified number(of characters)
|
|
|
|
|
one place to start would be to look at msdn.microsoft.com for iostream and fstream.
*.*
cin >> knowledge;
|
|
|
|
|
Hi! Keegan
I realy don't understand what you wanted to say...was just going through what you told me , but to no avail.....
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang98/html/_iostream_fstream.3a3a.fstream.asp
thats an insane description of fstream. I'll show you an example of one way to write to files here:
string filename = "data.txt";
ifstream inFile(filename.c_str());
ofstream Out;
string word;
inFIle >> word;
Out << word;
ifstream and ofstream are more or less identical in terms of use to cin and cout. Once you define the input and output streams, they work the exact same way (more or less). If you have any more questions, feel free to email me.
*.*
cin >> knowledge;
|
|
|
|
|
Consider using a CStdioFile for reading your file. Construct an instance of the class for the file you want to read from. You can call the ReadString method on it to get a line of text from your file into a CString. Then you can make use of all the methods of CString to get to only the part of the line in the string you are interested in. Technically you are reading the whole line. You then parse the string for what you need.
Lorenz Prem
Microsoft Corporation
|
|
|
|
|
Hello again,
I have a document-view app that uses a standard windows timer to display some animation on the view. The problem is, when I set the timer period to less than 200 msec (say 100 msec) some (or
all, I'm not sure) modal dialogs do not come to the foreground
and I have to press the "Alt" key to make them visible.
They all have the "Foreground" attribute set in the resource editor.
I read an article somewhere else in codeproject about attaching the main window thread to the dialog, but I don't get it.
When should I do this? Before I call DoModal() in my view, in the dialog's OnInitDialog() or what?
Thanks in advance.
|
|
|
|
|
You could try creating the dialog with WS_TOPMOST in the style parameter
|
|
|
|
|
Hi guys
How can I add code to the Standard Save on a menu of a SDI app?
Best Regards
Dr.Pi
|
|
|
|
|
|
If your using MFC override the Serialize() function in your derived class, call the base class function first and then add your code. I'm assuming you've set up the message map stuff for the standard save menu button correctly. If your using win32, then it depends...we need more info
|
|
|
|
|
Just noted JWood's response, if you want to do something extra before or after a save (pop a dialog box etc. then override OnSaveDocument(), but if you want to save extra stuff or mess with the io methods you'll need to override Serialize(). Hope this helps you. Check either of these methods out in MSDN for a deeper explanation. .
|
|
|
|
|
Thanks to everybody, I'll take a look on Serialize.
I had to save thinks like bool,float,arrays etc.. is then Serialize the place to do it? And then, later when I wanted to read it, is in Serialize too?
Best Regards
Dr. Pi
|
|
|
|
|
Replying to myself and waiting your answer.
I had to override serialize in each class where I have data to save, and then automatically when I call Save, all this data will be saved, and when I call Open, all this data will be retrieved (obviously if I implement correctly the serialize).
Is something like this?
if (ar.IsStoring())
{ // storing code
ar<<m_ncode
="" }
="" else
="" {="" loading="" code
="" ar="">>m_nCode
}
It doesnt' matter what m_nCode is?
Bast Regards
Dr.Pi
|
|
|
|
|
I know how to do this through explorer and how to 'open' and 'close' IO to the serial ports but I actually want to disable them.
How would I do this progmatically??
|
|
|
|
|
One solution is to disable the COM port. Check out this reference at MSDN.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/device_management_functions.asp
I am not familiar with serial ports, but try openning a connection and keep it alive at all time. That may block any I/O.
Kuphryn
|
|
|
|
|
dear all,
the following lines of code gives wrong value on windows 2000, but on every other operating systems it works fine
<br />
if (sDir.CompareNoCase("M") != 0)<br />
{<br />
.....<br />
}<br />
but if i use a variable with value "M"...it works fine.......
any guesses why
Regards
rIsHaBh
|
|
|
|
|
rishabhs wrote:
if (sDir.CompareNoCase("M") != 0)
use this instead..
if(!sDir.CompareNoCase("M"))
{
}
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
rishabhs wrote:
...the following lines of code gives wrong value...
Which means what? What does CompareNoCase() return in this case? What are you expecting it to return?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I assume sDir is a CString, you're not compiling for Unicode, and you're trying to test for sDir NOT being M (i.e. the if block should be executed if sDir is not M).
I can't see why this would fail on Windows 2000. CompareNoCase uses _tcsicmp , which translates to _stricmp for a non-MBCS, non-Unicode build. For an MBCS build, it translates to _mbsicmp . Check which of MBCS and/or UNICODE you're defining.
Apparently these functions are affected by the LC_CTYPE but not the LC_COLLATE locale parameter. I believe that the locale defaults to the C locale - see the documentation for setlocale .
See also the CodeProject BugList article[^].
|
|
|
|
|
This is probably a UNICODE vs. ANSI (MBCS) issue. If you change your code like this:
#include "tchar.h"
if (sDir.CompareNoCase(_T("M")) != 0)
{
}
that may help.
Software Zen: delete this;
|
|
|
|