|
Override the window procedure function. If message is WM_CLOSE, ignore it and return zero. This disables Alt+F4 usage completely. However, for a more effective solution, create a boolean variable inside the window's class. When the user attempts to quit the application by using a "legimate way", such as a menu selection or pressing the X button, then set the boolean to true, and allow the WM_CLOSE message to pass through, thus ending the application.
Your application can still be closed by pressing ESC or ENTER/RETURN, if it is a dialog-based application. Both methods are easy to disable: monitor for WM_KEYDOWN messages, and if the message is generated by ESC/RETURN/ENTER, ignore and return zero. Again, using a boolean variable allows to know whether it's a "legimate" press or an accidental one (entering a number into a field and pressing ENTER, for example)
If it is a standard Windows-application (non-dialog), then the ESC/RETURN/ENTER make no difference, I think. But you should test them all out nevertheless, as I don't want a 800 ton weight to drop on me
For all other key combinations used to end an application, here's perhaps-a-complete list: CTRL+F4, ALT+F4, ESC, RETURN and ENTER.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Anyone have any sample code on how to use CredUIConfirmCredentials with CredUIPromptForCredentials to verify local users on there computer.
Thanks
|
|
|
|
|
Anthony9887 wrote:
Anyone have any sample code on how to...verify local users on there computer.
Can you not use this, or are you stuck with CredUIConfirmCredentials() and CredUIPromptForCredentials() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yes, I'm stuck on using CredUIConfirmCredentials() with CredUIPromptForCredentials. Do you have a code sample on how to use both?
Thanks
|
|
|
|
|
Hello,
I am trying to write code to open an explorer window and highlight a given file in that folder.
I am using ShellExecute(hwnd, "explore", fileName, NULL, path, SW_SHOW) to do this but it does not always seem to work.
Is there a better way to do this?
Thank you,
Andy Moore
|
|
|
|
|
Andy Moore wrote:
but it does not always seem to work.
So it works sometimes and not others, is that correct? When it does not work, what are the symptoms? What is ShellExecute() 's return value?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have a app that runs on several PC.
My problem is that on some PC the text bmp's and rectangles are smaller.
The Monitors and PC are the same except for the graphic card.
I'm using MM_LOENGLISH and DeviceCaps are 96 on x and y on both PC's.
If I create a CRect top = -83, bottom = -38, left = 5, right = 95 and do a LPtoDP.
On one PC I get top = 54, bottom = 25, left = 3, right = 62 on the other
I get top = 80, bottom = 37, left = 5, right = 92?????
How do I make them all the same?
Please help!!!
Thanks in advance!
|
|
|
|
|
newbeetoc wrote:
DeviceCaps are 96 on x and y on both PC's
which DevCaps are 96? HORZSIZE, HORZRES, LOGPIXELSX ?
Software | Cleek
|
|
|
|
|
|
Hello,
I know that this may sound like a trival question, but I am trying to automatically generate the filter string for the lpstrFilter member of the OPENFILEDIALOG structure.
I look up the file extension in the registry and attempt to build the filter string by concatenating the string from the registry with the extension. I have not had much luck doing this. Perhaps is there an easier approach to this?
Thank you,
Andy Moore
|
|
|
|
|
Andy Moore wrote:
I look up the file extension in the registry and attempt to build the filter string by concatenating the string from the registry with the extension. I have not had much luck doing this.
Maybe it's just me but that does not tell me anything I can use to help.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
I guess basically what I am trying to do is if I have a file with a .zip extension, I want to call GetOpenFileName(&ofn) with the lpstrFilter set to filter only zip files, etc. I can look up HKCR/*.zip in the registry and get a string like "WinZip file". I am trying to generate the filter "WinZip Files (*.zip)\0*.zip\0".
I was wondering if there was already API functions that do this so I could avoid reinventing the wheel.
Thank you,
Andy Moore
|
|
|
|
|
nice idea.
Maybe AssocQueryStringByKey can help you, or IQueryAssociations.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks for the pointer. I will take a look at these.
Andy
|
|
|
|
|
Andy Moore wrote:
I am trying to generate the filter "WinZip Files (*.zip)\0*.zip\0".
Can you not just concatenate those two strings together using strcpy() /strcat() , or with a CString object if you are using MFC?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I am using ATL and wsprintf to try to build this string, but so far with no success. I will have to do some more debugging I guess.
Thanks,
Andy
|
|
|
|
|
what extension strings from the registry ? from HKEY_CLASSES_ROOT ? darn, all of them ?
This is something that needs to be done manually, it's too application dependent to automate from something like the registry ( IMHO ).
anyway, it's usually a one time thing.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hello,
I making an activex control in C++.
I need to create a property handler that will take in an enum:
enum Views {
aVIEW_DETAILS = LV_VIEW_DETAILS,
aVIEW_ICON = LV_VIEW_ICON,
aVIEW_LIST = LV_VIEW_LIST,
aVIEW_SMALLICON = LV_VIEW_SMALLICON,
aVIEW_TILE = LV_VIEW_TILE,
} ViewType;
ViewType CvbFileListCtrl::get_viewtype() {
}
void CvbFileListCtrl::set_viewtype(ViewType NewValue) {
}
Does anyone knows how to do this?
Please help!!!
iluha
|
|
|
|
|
Hi,
Does anyone know what is the way to change a CEdit's text color when the control is disabled?
I already implemented the reflected OnCtlColor, and it successfully changes the color when the control is enabled, but when disabled, the color becomes gray...
Thank you in advance.
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Vladimir Georgiev wrote:
...but when disabled, the color becomes gray...
This is normal (and expected) behavior. If you changed it to some other color, would the user know that the control was disabled, or would they try to interact with it and become frustrated when they couldn't?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I found a way to change the text color of a disabled CEdit.
1- You must derive a class from CEdit
2- Overwrite WindowProc and do the following:
LRESULT CMyEditBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_PAINT)
{
DWORD dwStyle = GetStyle();
if (dwStyle & WS_DISABLED)
{
EnableWindow(TRUE);
SetReadOnly(TRUE);
LRESULT res = CEdit::WindowProc(message, wParam, lParam);
SetRedraw(FALSE);
if ((dwStyle&ES_READONLY) == 0) SetReadOnly(FALSE);
EnableWindow(FALSE);
SetRedraw(TRUE);
CRect rcClient;
GetWindowRect(rcClient);
ScreenToClient(rcClient);
ValidateRect(rcClient);
return res;
}
}
return CEdit::WindowProc(message, wParam, lParam);
}
3- Overwrite CtlColor and change color when control is in read-only state (of course you can use a member variable instead of the read-only style to set disabled text color)
HBRUSH CMyEditBox::CtlColor(CDC* pDC, UINT nCtlColor)
{
if (GetStyle() & ES_READONLY)
{
pDC->SetBkColor(GetSysColor(COLOR_3DFACE));
pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
return GetSysColorBrush(COLOR_3DFACE);
}
return NULL;
}
|
|
|
|
|
I have written a Windows "Service" that logs on using the "Local System" account and "Interact with Desktop" enabled. This Service is used to launch my application (via the CreateProcess API) when the computer is started. My application's data is stored on a shared network drive. The problem is "Local System" normally does not have access to network resources because it logs on with null creditials. This can be solved by adding the "shared resource" to the "NullSessionShares" registry key on the Server that owns the "shared resource".
This seems to work and my application is able to connect to the shared resource using the WNETAddConnection2 API. However, when my application tries to access a file on the shared resource (using the GetFileAttributes API), it returns an error code 5 (access denied). I checked the permission settings on the "Shared Drive" and "Everyone" has full access to this drive.
Any idea why I can't access this drive?
Thanks in advance,
Petrus
|
|
|
|
|
Maybe because the "Local System" can't be part of the any network group by definition let alone the "Everyone" group. What do you think?
What about creating an account for the service and give it the required permissions.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
I'm not sure. I was reading "Microsoft Knowledge Base Artice 122702", which describs how to access a shared resource from a "Service", and it did not mention anything about adding/modifying accounts.
Peter
|
|
|
|
|
Petrus Scott wrote:
and it did not mention anything about adding/modifying accounts.
Perhaps so but further researching finds article 124184 which says:
Do not use the system account. Services, such as Scheduler, and custom applications can be configured using user-specific accounts. User-specific accounts provide user level security based on a specific account and associated password.
http://support.microsoft.com/default.aspx?scid=kb;en-us;124184&sd=tech[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|