|
How does one go about to implement handlers for buttons that are created dynamically at runtime? E.g. I want to create a button which should run a program when pressed. The program to run is configured by the user. I was thinking of storing the program name within the button object. Then I could use one handler for all of the buttons, but how do I know which button it was that called the handler (in order to retrieve the program name)?
Cheers,
/Fredrik
Do you Sonork? I do! 100.11430:PhatBoy
|
|
|
|
|
You can use ON_COMMAND_RANGE to handle a range of commands:
class CMyDialog : public CDialog
{
afx_msg void OnHandleCommands(UINT nID);
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
ON_COMMAND_RANGE(ID_COMMAND_FIRST, ID_COMMAND_LAST, OnHandleCommands)
END_MESSAGE_MAP()
void CMyDialog::OnHandleCommands(UINT nID)
{
// nID contains the ID of the command to handle
}
|
|
|
|
|
i have made a dialog.. resize it by hand (it's an easy one)
now i've tried to make this whole shista flickerfree.. but i don't get it flickerfree..
i've tried "clip children" and "clip siblings".. but it still flickers..
any ideas?
thanks in advance
bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
Override the dialog WM_ERASEBKGND message and do this :
BOOL CAnalysis::OnEraseBkgnd(CDC* pDC)
{
CRect clip ;
static int dont_erase_indexes[] =
{
IDC_WAVELENGTHS_LABEL,
IDC_COMPONENTS,
IDC_COMPONENTS_SPIN,
IDC_HSCROLL
} ;
pDC->SaveDC() ;
for (int i = 0 ; i < sizeof(dont_erase_indexes) / sizeof(int) ; i++)
{
GetDlgItem(dont_erase_indexes[i])->GetWindowRect(&clip);
ScreenToClient(&clip);
pDC->ExcludeClipRect(&clip);
}
pDC->GetClipBox(&clip);
pDC->FillSolidRect(clip, GetSysColor(COLOR_BTNFACE));
pDC->RestoreDC(-1) ;
return FALSE;
}
Just add the ID's of the control on the dialog to the static array.
Roger Allen
Sonork 100.10016
|
|
|
|
|
thank you for your reply..
now i know that i the control itself has got some problems with memory-drawing too..
but i really like that you can learn alot from code from other people
(i didn't knew that you could give -1 as a parameter to RestoreDC)
great thanks
Bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
|
Do you mean Common Gateway Interface or Computer Generated Images?
|
|
|
|
|
I mean Common Gateway Interface,such as all files of cgi-bin .
|
|
|
|
|
Normally (unless the admin has screwed up directory permissions) you can't download cgi files. The only thing you can get is what the cgi outputs.
Todd Smith
|
|
|
|
|
Hi, all!
Does anyone know the FASTEST way to reach RGB data contained in a CBitmap object?
In a prototype I use CDC::GetPixel, but I think it is highly sub-optimal.
May you help me?
Thanks
|
|
|
|
|
Copy it into a DIBSection, and you've got it in a BYTE**. For an example, check out my code online at www.wdj.com, in the Sept 2001 issue. I'll also point out it is stored BGR.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I have a program that uses Intel Performance Library Suite. Theprogram cannot be compiled. Error message is "fatal error LNK1104: cannot open file "ipl.lib". What should I do?
|
|
|
|
|
find that file on your disk, and make sure your project settings specify that directory as one of the lib directories.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I am developing an app using eVC 3.0 for WinCE. I was wondering if anyone knew how to get my windows title bar to be where the Start Command bar is and for my main window area start just under the command bar? I am using MFC and have created the window with rectDefault as the window size parameter. Since I can not post a picture of what it looks like please look at the following link for an example:
http://www.pocketprojects.com/ubb/Forum2/HTML/002767.html
Thanks,
-Eric
|
|
|
|
|
Hello All,
I am having some confusing problems with the above classes and need help. I have a COM interface that allows the user to build image list from several sources and different ways.
However, the images are finally stored in CImageList object. Now, I want to make it easier for the users to access any of the image items and render them. I provided the IPictureDisp interface (StdPicture in VB).
When the user request for an image item passing in the index, I convert the image to icon (CImageList::ExtractIcon), create CPictureHolder object and pass the IPictureDisp interface.
The problem is when the picture is rendered on the VB picture box, it turns to be black (cannot make up the image). However, if I load icons directly in the CPictureHolder and pass them to the VB, it works correctly.
What could be the difference between icons from CImageList and those loaded with ExtracIconsEx from files?
Best regards,
Paul.
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan, and open for programming contract anywhere!
|
|
|
|
|
I have created and displayed a file dialog to select multiple files. But when i select more then four files and hit enter or prell the ok button, the selection is erased and all that is left is the text in the entry box under the listbox. When trying to recover the files selected, the dialog box sends back nothing.
can some one help me pleeeeese
|
|
|
|
|
What flags do you pass to the constructor?
I usually use OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT
Maybe you can post some code?
Cheers,
/Fredrik
Do you Sonork? I do! 100.11430:PhatBoy
|
|
|
|
|
You have to allocate your own buffer for the returned files. The default buffer is too small.
TCHAR MyBuffer[1024];
CFileDialog fdlg;
fdlg.m_ofn.lpstrFile = MyBuffer;
fdlg.m_ofn.nMaxFile = 1024; Look up OPENFILENAME in MSDN.
---
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
IMHO, it is easier to use the functions of CFileDialog to retrieve the files.
Then you don't have to worry about buffer sizes.
CString strFileName("");
POSITION pos;
CStringList* strlistFileNames;
CFileDialog FileDlg(
true, // File Open dialog.
"*", // Default file name extension.
NULL, // No initial filename.
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT,
m_strNameMask + " (" + m_strSuffixMask + ")" + "|" + m_strSuffixMask + "|All Files (*.*)|*.*||"
);
FileDlg.m_ofn.lpstrTitle = "Select files";
pos = FileDlg.GetStartPosition();
while (pos != NULL)
{
strlistFileNames->AddTail(FileDlg.GetNextPathName(pos));
}
Cheers,
/Fredrik
Do you Sonork? I do! 100.11430:PhatBoy
|
|
|
|
|
From MSDN
<quote>
To allow the user to select multiple files, set the OFN_ALLOWMULTISELECT flag before calling DoModal. You need to supply your own filename buffer to accommodate the returned list of multiple filenames. Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal. Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile.
</quote>
---
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
Can someone point me in the right direction? The only way to access my app is via its tray icon. When Explorer does the nasty, it takes all the icons down with it. How can I detect that it has crashed and that my app needs to reinstall its icon?
I'm using Chris' CSystemTray, and PJ's CInstanceChecker, and Windows 98 (if that helps).
Thanks.
-Jason
nirgle.bitdevil.com
|
|
|
|
|
In Win 2K when explorer crashes [that's rare, very rare] it has the decency to bring back all the icons on the task tray
I guess what the user could do is to run your program again and your program can check for an earlier version using a mutex and then re-add the icon to the tray. You can check for its existence by sending a NIM_MODIFY message and if it fails it means the icon is not there [I hope so]
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Not true. I have never had an explorer crash in W2K where the task try icons were restored properly.
Best Regards
|
|
|
|
|
Bill Leibold wrote:
Not true. I have never had an explorer crash in W2K where the task try icons were restored properly.
I think that Nish is just lucky enough to have apps on his system that correctly handle that situation (i.e. the "TaskbarCreated" message )!
Peace!
-=- James.
|
|
|
|
|
personally, i'd install a timer, and in the timer proc (attempt to) remove the icon and reinstall it again. doing this every 5 seconds or so won't take much cpu time and should work ok.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|