|
I see what happened, I was returning in my WM_PAINT messages which was causing the huge CPU usage. I guess the DefSubclassProc must do something with WM_PAINT that causes the message not to be sent again; maybe by returning and not setting this parameter, the WM_PAINT was getting sent continuously.
Thanks for help!
KR
|
|
|
|
|
KellyR wrote: ...maybe by returning and not setting...
"Maybe"?
When working with window messages, you will have much better results if you
are sure about how to handle the messages, including proper return values.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am developing an VC application.
Whenever the user cliks on the exe, first the password dialog is to
be opened for user authentification.
So where can I store the password.
I am thinking about storing it in Registry.But is it the correct way of
storing the password?
Please clarify.
Regards,
Sunil Kumar
|
|
|
|
|
sunilkumar.d wrote: I am thinking about storing it in Registry.But is it the correct way of
storing the password?
I think you're confusing 'where to store' a password with 'how it should be stored' .. a password should never be stored anywhere as plain text - you should hash it with something like sha1 and store the hash [at a minimum]. When the user enters the password, you hash that and compare it to the stored hash and if there are the same, they are allowed access ...
Now, as to where to actually store the hashed/encrypted/obfuscated password - that depends on a lot of things .. will the password change and how often ? How will you handle updates - what happens if some other user needs to run the program from their PC ?? (etc etc) In the end, you must evaluate these questions vs how important the data/program is should it get into the wrong hands ..
.. and for anything but a trivial app I'd recommend looking at USB keys that you can issue to each user - then you have ultimate control
'g'
|
|
|
|
|
you can store the password in the registry, but there is a problem with that,you cant run in another computer. the best way is to store in a file or in a database.
|
|
|
|
|
Well there are many nice tricks!
as the friends said:
you can store it in registry (this is not the best way)
as you can store it in a database:
if your application uses databases, the best way is to create a table named SECURITY in which you put the password
another nice way is to put it in a file and give it System, Hidden attributes!, BUT in this you should encrypt your password (1)..
(1) there are easy ways to encrypt passwords or strings in general! just increment the ASCII code of all the characters by a value that you define (30 for example) in encryption function, and decrement it bye the same value in the decryption function, and you should put some rules (ASCII code 255 + 1 = 0, 255 + 2 = 1 ..)
--------------------------------------------
Some people dream of success while others wake-up and work hard to get it!
|
|
|
|
|
Hi All,
When i am porting a VC++ 6.0 application to VC++ 9.0, i am getting a assertion in keyboard handeller.
This is what i ma doing.
Mapping the function keys F1 thru F12 to bialog buttons. There is no assertion when i press F1 thru F11, but when i press the F12 key to activate that particular buttion, this is the message that is popping up with assertion.
"Windows has triggered a breakpoint in application.exe.
This may be due to a corruption of the heap, which indicates a bug in application.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while application.exe has focus.
The output window may have more diagnostic information."
Code:
CKeyDef *CKeyboardCtrl::HandleKeyboardMsg(MSG *pMsg)
{
UINT msgCode = pMsg->message;
switch (msgCode) {
case WM_SYSKEYDOWN:
msgCode = WM_KEYDOWN;
break;
case WM_SYSKEYUP:
msgCode = WM_KEYUP;
break;
}
ASSERT(msgCode == WM_KEYDOWN || msgCode == WM_KEYUP); //Assertion for F12
long keyCode = pMsg->wParam;
CKeyDef *pKey = LookupKeyCode(keyCode); //Assertion for F12
}
CKeyDef * CKeyboardCtrl::LookupKeyCode(long keyCode)
{
for (KeyList::iterator it=m_keyList.begin(); it != m_keyList.end(); it++) {
if (it->m_keyCode == keyCode)
return &*it;
}
return NULL;
}
Thanks Everyone.
|
|
|
|
|
F12 is debugger hotkey for breaking the execution. If you press F12 when your application is debugged, then debugger will catch it and break at current line of execution. Run your application standalone and your application will be able to catch F12. Nothing to worry that its expected behavior and not a porting bug.
To demo the F12 fact, Create a dialog application, run by F5, then take the dialog and press F12. The debugger will break to the current line of execution.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi raj,
Thanks. There is no assertion in release mode.
Thank you.
|
|
|
|
|
What i mean is if i want to hook a function
Somefunction(int arg1, int arg2);
Now this function has unique byte signature like /B2/C5/12/88.....
Is it possible to hook this function using the bytes and how would i do it?
|
|
|
|
|
What's the best way to have a certain menu only appear in DEBUG (or the reverse in RELEASE) ?
I've manually edited the resource file like this :
#ifdef _DEBUG
POPUP "Debug"
BEGIN
MENUITEM "Debug Command", IDM_DEMO
END
#endif
but I'm not certain this will survive future editing of the resources.
There's also a "Condition" for a whole menu, but that's a bit extreme.
I know I could add the menu programatically, but I'd like to be able to not have to do it.
Thanks.
|
|
|
|
|
Doesn't typing _DEBUG in the condition field do what you want?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
If your using MFC, then you can use a feature of your .rc file to do what you want:
If you open the .rc file as text you will find resources of type TEXTINCLUDE. If you add your menu definition code block as a string to one of these then it should quite happily persist between builds etc as VS preserves these resources "as is".
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\r\n"
"ifdef _DEBUG\r\n"
"IDR_MY_MENU MENU DISCARDABLE\r\n"
"BEGIN\r\n"
" MENUITEM ""Debug Command"", IDM_DEMO\r\n"
"END\r\n"
"#endif\r\n\0"
END
If you vote me down, my score will only get lower
|
|
|
|
|
that's a christmas gift...
will try it next year when I go back to work.
This signature was proudly tested on animals.
|
|
|
|
|
I'd like to be able to display a message on a WinXP computer which has been locked. This needs to be workable on both a machine which is locally locked (the user hit Windows-L and walked away) or a machine which is being used remotely. In either case, Windows displays the desktop wallpaper with a dialog box entitled "Computer Locked".
I can modify the wallpaper and I know how to change the title of the locked dialog box. These, however, are only static methods. I'd like to be able to but up a message that could be changed by the remote user. For instance "I'll expect to be finished with this machine by 2:30 today.".
My application is for lab machines which are used by both walkin and remote users. When someone walks up to a machine, they would like to know the status of that machine. If a remote user is using it, it would be helpful if they could update their status as needed so it displays on the machine.
Anyone know how I can direct output to this locked desktop?
Thanks
Al
|
|
|
|
|
Hi,
Sorry I can't help with the code, but are you convinced you have the right answer to your problem and users will update it as you want? You might end up with all your computers displaying "busy" or, or if requiring a time entered, you might just get most people entering some late time to make sure nobody user 'their' computer whilst they go for a drink!
|
|
|
|
|
I can see you've been there also . My real issue is with remote users that are using a machine but it appears that someone has just walked away for a while and other users get upset and log them out. The ability to stick a virtual postit note on the screen will help with this.
|
|
|
|
|
Hi everyone,
I would like to install a Vista Gadget programmatically from a win32 application. It appears at first sight that adding a gadget just consists in deploying a couple of files and adding a bunch of entry in the settings.ini
file, but there are two issues:
1/ When I update the settings.ini file to create the section for the new gadget the sidebar is not updated and I have to restart the process to get the new gadget displayed. Do you know if there is some kind of messages I can send to the sidebar to refresh its content?
2/ There is a Hashes section in the settings.ini file that lists every gadget available. Each entry contains the complete path to the gadget folder plus a hash value. Does anyone know how this value is computed?
Thank you for your help,
Yannick
|
|
|
|
|
Hi Frnds,
I have developed one application in visual studio 6.0. it will communicate with one PCB via RS485. The problem am facing in the application, sometimes if i close the application, the exe is running at the back side, am closing it suing task manager. i have closed the handles of the RS485 communication at the deconstructor of my class.
Request anyone help.
Thanks ,
Balaji s
|
|
|
|
|
Hi,
I've seen similar problems. The first thing I would recomend is to write Open and Close methods. Make sure you check the return values for any errors and display a message box with any error so you can se exactly what the problem is. Then add calls to these from, say, a menu. E.g. a Comms menu with Open and Close options. This will allow you to test if the port truly gets closed when you call Close. Can you then perform Open, Close, Open, Close with no problems?
This separates closing the port from the closing of the application.
Once the Close is proven, then add it to the OnClose window event rather than the destructor.
I'm afraid I don't understand what you mean about closing the application but the exe still running. Do you have a client and server and you close the client in task manager but the server (exe) is still running?
|
|
|
|
|
Hi,
Thanks for your reply.
am using the write , read and close functions.after closing my application, if i try to open once again, it says that still exe is running. so i used to task manager to close th exe.
thats the problem happening here.
regards,
balaji sk
|
|
|
|
|
Well, I'm not sure how much significant is my reply. Usage of TerminateThread()[^] can end up in application handups. If you're calling them just remove it.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
As I've noticed, Windows Explorer uses the icon with the lowest ID within an EXE file to represent it to the user. Is there any way to change this Icon for EXE files dynamically? (I mean replacing it with a custom one)
Thank you masters!
|
|
|
|
|
This pretty girl[^] knows how to replace resources in EXE and DLL files. She probably also knows how to use the codeproject search engine. How does that make you feel?
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: This pretty girl[^]
At first i didn't understand it. Once i opened the link, i got it.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|