|
Hi All,
A brief about the prob I am facing. We have a dialog being displayed (has got property pages)... In one particular property page.. we have 2 radio buttons... (other controls not in question)... we display a dialog whenever the user tries to change the selection of the radio control. Say from "radio1" to "radio2"... It's basically a simple Yes/No question messagebox. If the the user selects "yes" the user is allowed to select the other radio button, otherwise not.
"radio1" is selected by default. User changes to radio2. after selection... dialog appears (asking for confirmation). If the user says "yes" then we continue as it is, otherwise we progra-matically restore the first radio controls state (selected=true) by setting m_nFirstRadio=1. this is the variable controlling the state of these two controls.
We are hadling the OnRadioButton() message handler for both of these controls.
Till now it works perfectly.
but when we change the property page to some other at runtime.. I don't know why.. but the message handler for the radioButton is being called (about 18 times). In effect displaying the conformation dialog about 18 times...
Any idea why this is happening??? I am not calling the OnRadioButton message handler manually. One more thing.. this happens only when the user selects "no".. thus we had to restore the state programatically.
Is there any rule as to when to use the radio button's member variable to change the state...
Regards,
Mohit
|
|
|
|
|
Your are already sitting on the answer.
Your change the state of the other radio buttons manually, therefore you generate
OnRadioButton messages.
As a workaround You could set a flag when You are changing the state of the buttons manually
and check for this flag in the OnRadioButton handler.
Yours,
Alois Kraus
|
|
|
|
|
Hi Alois,
But the message shoudl be generated only once if at all. Since I click on the radio button only once, and then say "no" in the confirmation dialog. So the state is restored. Below is the code in the handlers "Locked" and "UnLocked" both are radio buttons. m_nRadLocked controls the state.
Why the handler is being called 18 times.. and that too when I am changing to a different property page using the tab control.
Somebody told me that this is a BUG with VC++/MFC. And happens when we use AfxMessageBox/and radio buttons. But I really don't think so. So thats why I had mailed the forum.
property page looks somewhat like this:
/----------------------------------------\
| |
| O Locked O Unlocked |
| |
| some other controls ------ |
\----------------------------------------/
void CSDT12ConfigDCCPage::OnRadUnlocked()
{
UpdateData();
// If Board Admin State locked,
// We shoul not allow to change Admin State of Port to Unclocked state
if(((CSDT12ParentDialog*)m_pParent)->GetAdminState() == 1)
{
m_nRadLocked = 0;
UpdateData(FALSE);
}
}
void CSDT12ConfigDCCPage::OnRadLocked()
{
UpdateData();
/* this condition is to avoid the handler to be called un-neccesarily */
/* if this condition is not present.. dialog is called 18 times while */
/* changing property page to another */
if (m_nRadLocked == 0) /* Check if this msg handler is really being called*/
{
if (AfxMessageBox(IDS_SDT12_BOARD_LOCKED_WARNING,
MB_YESNO | MB_DEFBUTTON2 |MB_ICONQUESTION) == IDNO)
{
m_nRadLocked = 1;
UpdateData(FALSE);
}
}
}
Regards,
Mohit
|
|
|
|
|
HI
I have some buttons that I am linking to ShellExecutes, but in this program the parameters to some of the ShellExec are an unknown filename. Also, some of the files to Exec are unknown filenames.
I know the directory and extension of the files I want to exec, but the actual names of the files changes.
Also, there will only be max of one file of each extension to Exec.
If the file does not exist, I want the button to be greyed out.
Does anyone have any insight in how to go about any of this, or what functions to look at? Is there an "anything" character, or is FileFind someplace I should be looking?
Thanks!
|
|
|
|
|
just use ShellExecutes and "open" to "execute" file,windows can lookup register and find proper program to open it
use :
BOOL PathFileExists(
LPCTSTR pszPath
);
to test the does the fileexisted
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
I have the following situation:
Class A:
{
public:
virtual void getValue (float& val) const
{val = 5.0f;}
virtual void getValue(bool& val) const
{ val = true;}
virtual void getValue(string& val) const
{ val= "abcd";}
}
class FloatA: public A
{
public:
virtual void getValue (float& val) const
{val = 10.0f;}
}
class BoolA: public A
{
public:
virtual void getValue (float& val) const
{val = true);
}
I figured out that calling the float function take 20 times time than the bool function !
Any idea ???
Is it the float type (it is happened also with double) ?
Is it the overloading order ?
|
|
|
|
|
bool was prodess as short int
process speed of float is slowly than int
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
|
|
hi
i m makg a windows browser based applction with 2 panes :
left derived from CTreeView and right from CHtmlView.
iwant to access object of CHtml derived class from CleftView
can any hlp me out
|
|
|
|
|
Use their common ancestor (probably it's the MainFrame, or a ChildFrame for MDI apps)
A rock pile ceases to be a rock pile the moment a single man contemplates it, bearing within him the image of a Cathedral[^].
Antoine de Saint-Exupery (1900-1944)
|
|
|
|
|
This is the common case of the document view architecture. In the doc should the data-objects (very good for serialization) and with pointers/interfaces to them you get the data which you can disaply in the views.
PS: Editing and modifying functions are best implemented in the mainframe so EACH view can access them.
Try this @ home. (B&B)
|
|
|
|
|
use global pointer
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
hi,
Do it via your splitter wnd
CMainFrame::GetInfo()
{
CSplitterWnd* pSplitter = &m_wndSplitter;
ASSERT_VALID( pSplitter );
CWnd *pPaneWnd = pSplitter->GetPane(0, 0);
CLeftView* pTreeView = static_cast<cleftview*>(pPaneWnd);
ASSERT_VALID( pTreeView );
ASSERT_KINDOF( CTreeView, pTreeView );
HTREEITEM hItem;
hItem = pTreeView->GetTreeCtrl().GetSelectedItem();
or
CWnd *pPaneWndTwo = pSplitter->GetPane(0, 1);
CHtmlView* pHtmlView = static_cast<chtmlview*>(pPaneWndTwo);
ASSERT_VALID( pHtmlView );
ASSERT_KINDOF( CHtmlView, pHtmlView );
}
include your HtmlView.h in your file where to call it
hope it helps,
|
|
|
|
|
hi
u got it exactly right,thts wht i wanted to do.
thx for ur help
bye
|
|
|
|
|
Hi,
Is there anyway to increase the dialog border width?
Regards
Neha
|
|
|
|
|
Use the MoveWindow function
Ex. MoveWindow(&myRect, TRUE);
|
|
|
|
|
You can do that in a number of ways.
1) you can use WM_NCCALCSIZE to recalculate the size of the client area for your window or dialog, by reducing the default size of your client area that will increase the size of the borders.
2) You can handle the WM_NCHITTEST yourself, and return the HTRIGHT, HTBOTTOM etc for all of the border cases, and increase the dimensions that count as the border. This will make all of the other default message handlers act as if the border is wider.
In either of these cases I would handle the WM_NCPAINT message in order to paint and extend the appearance of hte width of the new border that you create.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
|
Hi,
My program can now uninstall itself with a "-u" argument; and it'd invoked by CP->Add/Remove Programs just fine.
My question is, what is the proper way to delete my uninstall app's file itself? I can't delete it because it's locked when i'm running the app.
My only thought is to use HKLM/Software/Microsoft/Windows/CurrentVersion/RunOnce, and a cmd entry to delete the file, but this isn't really very smart. Surely there's a better way? How does installshield do it?
Thanks
Jon
#include <beer.h>
|
|
|
|
|
There is an MSDN article somewhere about different ways of doing this... but I can't seem to find it at the moment...
But anyway - the way to do this consistently on all OSes (9X, NT, 2000, XP), without having to wait for a reboot, is to use a batch file.
Let's say you have an uninstaller called Uninstall.exe. At run-time, right before your uninstaller exits, it should create a batch file in a temp directory somewhere that tries to delete Uninstall.exe, and once it succeeds, deletes itself. Here's an example to get you started (this originally came from an MSDN article, but has been hacked up a little bit ).
Note, you'll want to clean this up, there is no error checking, and some paths/filenames are hard-coded.
<code>
void DeleteThyself()
{
TCHAR unstFileName[] = "Uninstall.exe";
TCHAR tempDir[MAX_PATH];
DWORD error = 0;
::GetTempPath(MAX_PATH, tempDir);
TCHAR batFileName[MAX_PATH];
_tcscpy(batFileName, tempDir);
_tcscat(batFileName, "UnstTmp.bat");
ofstream batchFile(batFileName);
batchFile << ":Repeat\n";
batchFile << "del \"" << unstFileName << "\"\n";
batchFile << "if exist \"" << unstFileName << "\" goto Repeat\n";
batchFile << "del \"" << batFileName << "\"\n";
batchFile.close();
STARTUPINFO si;
PROCESS_INFORMATION pi;
::ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
if(::CreateProcess(NULL, batFileName, NULL, NULL, FALSE, IDLE_PRIORITY_CLASS, NULL, tempDir, &si, &pi))
{
::SetThreadPriority(pi.hThread, THREAD_PRIORITY_IDLE);
return true;
}
}
Even a broken clock is right twice a day.
|
|
|
|
|
DeleteMe.CPP
Module name: DeleteMe.cpp
Written by: Jeffrey Richter
Description: Allows an EXEcutable file to delete itself
********************************************************************/
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
/////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE h, HINSTANCE b, LPSTR psz, int n) {
// Is this the Original EXE or the clone EXE?
// If the command-line 1 argument, this is the Original EXE
// If the command-line >1 argument, this is the clone EXE
if (__argc == 1) {
// Original EXE: Spawn clone EXE to delete this EXE
// Copy this EXEcutable image into the user's temp directory
TCHAR szPathOrig[_MAX_PATH], szPathClone[_MAX_PATH];
GetModuleFileName(NULL, szPathOrig, _MAX_PATH);
GetTempPath(_MAX_PATH, szPathClone);
GetTempFileName(szPathClone, __TEXT("Del"), 0, szPathClone);
CopyFile(szPathOrig, szPathClone, FALSE);
// Open the clone EXE using FILE_FLAG_DELETE_ON_CLOSE
HANDLE hfile = CreateFile(szPathClone, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
// Spawn the clone EXE passing it our EXE's process handle
// and the full path name to the Original EXE file.
TCHAR szCmdLine[512];
HANDLE hProcessOrig = OpenProcess(SYNCHRONIZE, TRUE, GetCurrentProcessId());
wsprintf(szCmdLine, __TEXT("%s %d \"%s\""), szPathClone, hProcessOrig, szPathOrig);
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
CreateProcess(NULL, szCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
CloseHandle(hProcessOrig);
CloseHandle(hfile);
// This original process can now terminate.
} else {
// Clone EXE: When original EXE terminates, delete it
HANDLE hProcessOrig = (HANDLE) _ttoi(__targv[1]);
WaitForSingleObject(hProcessOrig, INFINITE);
CloseHandle(hProcessOrig);
DeleteFile(__targv[2]);
// Insert code here to remove the subdirectory too (if desired).
// The system will delete the clone EXE automatically
// because it was opened with FILE_FLAG_DELETE_ON_CLOSE
}
return(0);
}
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Code like this was shown in an MSDN article. I think it only works for 9X though.
Even a broken clock is right twice a day.
|
|
|
|
|
i want to make my mouse pointer not to move close to the top of my client area of a window.i should make it to stop below 20 pixels from the top of the client area.how to do it.
|
|
|
|
|
Take a look at the API function ClipCursor()
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|
|