|
The simplest solution, working well, and you won't need to override anything of CEdit class:
void CTestDlg::OnBtnClickedCancel()
{
CWnd* pWnd = GetFocus();
if(pWnd == dynamic_cast<CWnd*>(&m_ctlEditMultiline)) {
return;
}
OnCancel();
}
Maxwell Chen
|
|
|
|
|
Yes, If you handle the ESC key in the upmost dialogbox, the there will be many if there. If the focus is in a edit box then blablala, and If the focus is in a listctrl then something else.
This is why I appreciate handling the WM_GETDLGCODE message. Then each control has its own way to handle key message. I believe the code will be cleaner. But it doesn't works well for multiline CEdit ctrls.
Any way, Thank you Maxwell Chen
A Chinese VC++ programmer
|
|
|
|
|
Maxwell Chen
|
|
|
|
|
I want to write a small program to play-back the video media on a Blu-ray disc.
But i found it is difficult.
Someone tells me the files have been encrypted. I know some other videos would be encrypted,dvd and so on,but only copying is forbidden(playing is allowed).
Then,how should I play the videos on a Blu-ray disc? If the video should be decrypted,how should i implement it?
Regards.
|
|
|
|
|
I am writing a code in C++ to read out a Registry key Value. The program runs with no errors but instead of reading the value either shows nothing (in case value == 0) or shows funny face symbols (if value == 1 or other values). Once this value is read I would also need to assign it to a variable. Any solution would be highly appreaciated!
///// code /////
HKEY MyKey;
unsigned long type=REG_SZ, size=1024;
char res[1024]="";
RegOpenKeyEx
(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\0", 0, KEY_READ, &MyKey);
RegQueryValueEx
(MyKey, "1400\0", NULL, &type, (LPBYTE)&res[0], &size);
cout << "Ant the value is.....: " << *(LPBYTE)&res[0] << endl;
RegCloseKey (MyKey);
///////////////////
|
|
|
|
|
Why are you unnecessarily adding \0 to the string literals.
J_E_D_I wrote: RegQueryValueEx
(MyKey, "1400\0", NULL, &type, (LPBYTE)&res[0], &size);
Why are you not reading this into a DWORD type?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How the heck did you determine it should be a DWORD from that code???
I'm way more curious about the LPBYTE cast when displaying the "string"...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ahh now I see it (the DWORD) in the registry
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
(I swear yesterday I saw my message succesfully posted on the website, but today I can't find it anymore! So I'm posting it again).
David, I followed your advice and tried to read it into a DWORD type, but still it doesn't seem to work. What am I doing wrong? Besides reading the registry value, I need to assign it to a variable. Help please!
HKEY MyKey;
DWORD dwLen = sizeof(DWORD);
DWORD dwKeyEn = 0;
RegOpenKeyEx
(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", 0, KEY_READ, &MyKey);
RegQueryValueEx(hKey, "1400", NULL, NULL,(LPBYTE)&KeyEn, &dwLen);
cout << "And the value is.....: " << *(LPBYTE)&KeyEn << endl;
RegCloseKey (MyKey);
|
|
|
|
|
J_E_D_I wrote: (I swear yesterday I saw my message succesfully posted on the website, but today I can't find it anymore! So I'm posting it again).
The search feature is sometimes cantankerous.
J_E_D_I wrote: RegQueryValueEx(hKey, "1400", NULL, NULL,(LPBYTE)&KeyEn, &dwLen);
cout << "And the value is.....: " << *(LPBYTE)&KeyEn << endl;
Should probably be:
RegQueryValueEx(hKey, "1400", NULL, NULL, (LPBYTE)&dwKeyEn, &dwLen);
cout << "And the value is.....: " << dwKeyEn << endl;
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
With your modifications it doesn't show the funny symbols anymore..but it always returns "0" (as defined above by "DWORD dwKeyEn = 0", I guess) rather than reading the actual value from the registry.
|
|
|
|
|
So does HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1400 actually exist, and does it have a non-zero value? I tried this on my machine and it worked fine. You might verify that the last argument to RegOpenKeyEx() and the first argument to RegQueryValueEx() have the same value.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Wonderful, it works! I'm very grateful for your help. Send me a picture...and I'll make you a statue! How silly, I made a typing mistake writing hKey rather than MyKey in RegOpenKeyEx().
|
|
|
|
|
1 )I am implementing a component that receives an event , which needs to launch an exe
However , I do not want to launch the exe if it is already running .
Is there a way to determinie if the exe is currently running ?
2)Typically there are applications that are launched the first time when an event occurs .
Say Windows media player is launched when i connect my music player
However I would want to understand how these applications get notified when subsequent events ( non-first time events ) occur ? Is there a standard pattern to follow ?
I was thinking, more on the lines of the App ( such as Windows Media player) that acts as a client to a Com Server ( which receives the notifications) , however the non first time notifications would be conveyed via a callback ( registered during initialization of the EXE ) .
Ideas are welcome
Thanks
Engineering is the effort !
|
|
|
|
|
act_x wrote: 2)Typically there are applications that are launched the first time when an event occurs .
Say Windows media player is launched when i connect my music player
However I would want to understand how these applications get notified when subsequent events ( non-first time events ) occur ? Is there a standard pattern to follow ?
WMP has code in it that checks to see if it is already running.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Further to David's comments on the application doing the checking for this, try a search for the term 'single instance' in the articles. Here's two articles that I'd recommend;
1). MFC and C++[^]
2). Managed .Net[^].
|
|
|
|
|
2) When a New Device (like your music player) is plugged in, a Window Message ( WM_DEVICECHANGE ) is sent to all the resident windows... All you need to do is create a resident application with a hidden window...The window will recieve A WM_DEVICECHANGE Message...this is where you detect whether it's a viable device...
There's also a "RegisterDeviceNotification " (though, i'm not familiar with it...)
I'm not sure if this was what you were expecting? Is there any specfic event you want to "listen" to?
modified on Thursday, February 21, 2008 9:35 AM
modified 20-Oct-19 21:02pm.
|
|
|
|
|
I need to modify a few C applications that are about 10 years old and are currently using CMC to send and receive email from Exchange. I tried using Simple MAPI but am encountering the Outlook security prompts, so I am now looking at using Extended MAPI. I have found examples here using C++, but nothing written in C. Microsoft does not seem to offer much in the way of examples and rewriting the applications in C++ is not an option because there are several custom libraries that would also need to be converted. One of the applications is loaded on about 15,000 workstations, so a third party product or a loading a custom dll is not an option either. The only functionality I need is to be able to logon, logoff, send email and read email (in plain text). Any ideas ??
|
|
|
|
|
This doesn't add up. You don't need to rewrite the whole application in C++. You should be able to interface the legacy C code with any C++ changes.
Write a C interface to the C++ code:
#include "NewCppAPI.h"
void legacy_Code()
{
int iResult = NewCppAPI();
}
#ifdef __cplusplus
extern "C" {
#endif
int NewCppAPI();
#ifdef __cplusplus
}
#endif
#include "NewCppAPI.h"
int NewCppAPI()
{
int iResult = 0;
return iResult;
}
I have to guess that there must be some other constraints you are not mentioning.
|
|
|
|
|
further...I would anticipate that you might need to interface to the legacy C code from the C++ code. In the C++ code mark the legacy C headers as C code:
extern int stableAPI(int icount);
extern "C" {
#include "legacycode.h"
}
void CppFunction()
{
std::vector <int> vNumbers;
vNumbers.push(1);
vNumbers.push(2);
vNumbers.push(3);
int iResult = stableAPI(vNumbers.size());
}
When you have to pass information to the legacy code, it can only pass C types; don't pass pointers to C++ types. Be sure you know who owns what memory. A simple solution is to write copy API's in the C++ code that are called by the legacy C code in the same way that windows API's do. You pass in a pointer to a buffer with a pointer to a length that is the size of the buffer. If the buffer is too small the function returns an error and set the length to the size needed:
int CopyCppData(char * pszBuffer, int * ilength);
|
|
|
|
|
Hi,
I am getting error while compling my C++ code when I am using SafeArrayGetElement method in Unix.It is complining successfully in Windows.
Is there any equalent method for SafeArrayGetElement for getting each element from safearray in Unix enviroment?
Thanks in Advance
JK
|
|
|
|
|
AFAIK the aren't SafeArray s at all in UNIX .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi all..
I am creating a Log File..I want to use locking and unlocking function...I dnt have idea abt threading..plz give me some idea..
thanking you
sharan
Hi,,
I am sharan.Working as a software Engineer in Indo-Fuji Software Company located in BTM Layout.Bangalore.India.
I have Completed my B.E(COmputers)in 2006.ANd I am having 2 years of Exp in VC++.
thanking you
sharan
|
|
|
|
|
What are you trying to "lock"? Are you trying to prevent simultaneous access to the file?
If so, between separate processes? Threads of the same process?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi..
I am trying to lock a log file...
I am creating a log file...which will be opened once...
i will write log errors to that....
i want to use locking so that no one else can write to that log file...
Hi,,
I am sharan.Working as a software Engineer in Indo-Fuji Software Company located in BTM Layout.Bangalore.India.
I have Completed my B.E(COmputers)in 2006.ANd I am having 2 years of Exp in VC++.
thanking you
sharan
|
|
|
|