|
thank you Cedric.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
I was wondering what would be the best way to implement the following:
I have many types of objects that have a similar function the same. I want a main Messaging class to route commands to each respective object to do something when something specific happen related to the object. A use for this would be to have multiple graphs that would be plotting different thing with the same data. However the main difference is that I could change things at runtime by attaching this graph to this and that graph to that.
Any ideas? Anything I can read to do what I would like?
Appreciate any help.
Thanks.
|
|
|
|
|
I am not quite sure if it is what you want, but have a look at the 'signals and slots' library from boost[^].
Boost is a repository for libraries and tools that faciliate modern C++-programming, especially STL and templates. Many of the people at boost are activly participating at the C++ standardisation comitee.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I was going to suggest Signals & Slots as well. Besides Boost there is also LibSigC++ which I'm using in ED. I tried to use Boost 'signals & slots' recently to compare it with LibSigC++ but had to give up because the signal was in a DLL and the slot in the Exe. LibSigC++ handles this without any problems.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
The best way to implement this is to use the OBSERVER pattern described in "Design Patterns" book.
You can find here some example for that:
http://www.codeproject.com/cpp/observer.asp
http://www.codeproject.com/useritems/Observer_with_templates.asp
http://www.codeproject.com/gen/design/ObserverPattern.asp
|
|
|
|
|
One question:
I'm try to get the folder name with SHBrowseFolder() and want to create a new folder on folder-browsing dialog
by clicking right button(popup menu) or clicking 'new folder' button I have made if possible.
On MSDN, 'ulFlags' field in BROWSEINFO structure includes a flag following.
BIF_NONEWFOLDERBUTTON
Version 6.0. Do not include the New Folder button in the browse dialog box
I suppose SHBrowseFolder() has a 'Create new folder' button as a default according to that flag.
But when SHBrowseFolder() runs, there is no 'Create new folder'.
And to my suprise, not only BIF_NONEWFOLDERBUTTON flag but also half of flags in 'uiFlags' field are not defined in 'shlobj.h'.
Of course, I'm using Visual Studio 6.0.
In short, I hope to create new folder on folder-browsing dialog by all means.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The other question:
After a format dialog is created by running SHFormatDrive(), pressing a 'Start' button progresses formatting.
Though formatting was completed, the format dialog never disappear.
Only the format dialog don't disappear until 'Close' button is pressed.
That is, a blocking happens until 'Close' button is pressed.
I wanted to progress my routine for copying files immediately, after formatting is completed.
So I coded like this.
void CSetDlg::OnButtonMakeDisk()
{
.
.
.
if( AfxMessageBox("Not a sufficient space in a diskette.\n\nDo you want to format a diskette?", MB_YESNO) == IDYES)
{
if( SHFormatDrive(this->GetSafeHwnd(), m_ComboDrive.GetCurSel(), SHFMT_ID_DEFAULT, 1) != SHFMT_ID_DEFAULT )
return;
}
else
return;
.
.
Here is my routine for copying files...
.
.
}
However, though I press 'Start' button for diskette formatting,
I should press 'Close' button for ending of format dialog.
So, SHFormatDrive() always returns SHFMT_CANCEL and OnButtonMakeDisk() terminate.
How can I progress my routine for copying files immediately, after formatting is completed ?
Subclassing? Message hooking?
I cannot get the ID or Message of 'Start' button on a format dialog.
Please advise me... help me...
I'll wait your good advices.
|
|
|
|
|
To your first question:
Did you install the latest Platform-SDK? It updates any number of headers to support API-functions in current Windows versions.
You can download it from Microsoft for free, or you get it with the MSDN-CDs.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
guys.. .i need a help.
Can anyone tell me how to load a MFC DLL explicitly so that I can load the appropriate version and also unload it? Please note that I am exporting a class from DLL.
thanks
Bhaskar
___________________________
"Think big, think fast, think ahead. Ideas are no one's monopoly"
|
|
|
|
|
::LoadLibrary()
::ReleaseLibrary()
|
|
|
|
|
This article of mine does dynamic loading of MFC extension DLLs, so if you look into the code, it should help you do what you need.
http://www.codeproject.com/library/PIArchitecture.asp[^]
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
thanks, I will check the URL you mentioned.
___________________________
"Think big, think fast, think ahead. Ideas are no one's monopoly"
|
|
|
|
|
hi
i have dialog with controls and tab ctrl around them
it is not property sheet
so i'm dynamicaly showing controls with tab change
all is ok till you not run it with xp look
there tab gets view background color (white-to-ligh-gray effect, not dialog one)
but controls of course keep dialog color (dark gray at mine)
(it looks making them transparent is not solution?)
look at net sources they have another problem:
their tabs are always dialog-colored(even comparing window flags i do not see reason)
http://www.codeproject.com/tabctrl/ctabctrlssl.asp?msg=516747#xx516747xx
http://www.codeproject.com/tabctrl/stabctrl.asp?msg=223289#xx223289xx
http://www.codeproject.com/tabctrl/cxtabcontrol.asp?msg=516765#xx516765xx
http://www.codeguru.com/mfc/comments/51497.shtml
my experiment with creating control like tab's child failed - it still draws own dialog-background rectangle
SetBkMode(TRANSPARENT) into OnCtlColor too
do i really need subclass all controls to disable them backgound drawing or similar?
is there any way to use tabs into dialogs 'xp correctly' without change to property sheet?
but what with more tab ctrls into dialog?
thanks for ideas
t!
(http://www.codeguru.com/forum/showthread.php?s=&threadid=249227)
|
|
|
|
|
I bring this back on top, because at the moment i got the same problem. Radio- ,Check-Buttons and Groupboxes will not accept the SetBkMode(TRANSPARENT) in OnCtlColor() so there backround is still darker then
the background of Tab control. Any solution ?
Thanks
Marc
|
|
|
|
|
hi...
How do you add two LPTSTR variable togeter?
|
|
|
|
|
That's just a char *, isn't it ? Use strcat, assuming you can't turn them into strings.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Actually LPTSTR is an LPWSTR if UNICODE is defined, an LPSTR otherwise, so use _tcscat() ... assuming of course that the first LPTSTR points to a buffer large enough to hold the result.
...cmk
|
|
|
|
|
strcat will do the trick, even if youre using UNICODE
|
|
|
|
|
Ernesto D. wrote:
even if youre using UNICODE
No it won't. First of all, an LPTSTR is a wchar_t* is you've compiled for UNICODE, and strcat is prototyped for char * strings. Second, and more importantly, even if you type-cast away the compiler warnings, strcat still won't work. In a UNICODE string, characters are two bytes. If either the upper or lower byte of the character in a UNICODE string is zero, the strcat will terminate early. The terminator for a wchar_t string is 0x0000 (a word, not just a byte). Therefore, you should use _tcscat(...) .
Software Zen: delete this;
|
|
|
|
|
Hi!
Please, help me to resolve a simple problem. I can't catch OnClose() notification in the CSocket-derived class. What's wrong? However, OnSend() and OnReceive() work fine.
Maybe, Does anybody know useful trick?
/////////////////////////////////////////////////////////////////////////////
// CNetClientSock command target
class CNetClientSock : public CSocket
{
// Attributes
public:
// Operations
public:
CNetClientSock();
virtual ~CNetClientSock();
// Overrides
public:
CWinThread* m_pThread;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNetClientSock)
public:
virtual void OnClose(int nErrorCode);
virtual void OnSend(int nErrorCode);
virtual void OnReceive(int nErrorCode);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CNetClientSock)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
protected:
};
void CNetClientSock::OnClose(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
m_pThread->PostThreadMessage(WM_QUIT,0,0);
CSocket::OnClose(nErrorCode);
}
Yours sincerely,
Alex Bash
|
|
|
|
|
I want to import a function from vb dll in VC. Is it possible? How should I import it?
|
|
|
|
|
Hi!, im not shure about this but, you could try loading it with LoadLibrary() and use it with GetProcAddress(), (check out the documentation for this functions on MSDN)
HTH
|
|
|
|
|
Is it a regular DLL or an ActiveX/COM dll.
If it is an ActiveX dll, you can use #import
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
I am using CListCtrl. I want to display yhe icon along with the item I have done it in following way But it is not displaying the image What could be the problem?
HICON hIcon;
CImageList m_imageList;
m_imageList.Create(16, 16, 0, 1, 1);
hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
m_imageList.Add(hIcon);
pList->SetImageList(&m_imageList, LVSIL_SMALL);
pList->InsertItem( 0, "RED", 0 );
|
|
|
|
|
Perhaps the icon is not a 16x16 icon? Try using a 16x16 bitmap resource instead.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I have made a struct as shown below, and I want to create an array of this struct
struct PASSACCOUNT {
CString sGroupName;
CString sAccountName;
CString sUsername;
CString sPassphrase;
CString sAccountNotes;
CString sUrl;
CTime ctCreationDate;
CTime ctExpiresDate;
CTime ctModifiedDate;
};
When I attempt to declare it: CArray<PASSACCOUNT,PASSACCOUNT> pg; I get the error:
error C2059: syntax error : '<'
Is it possible to create an array of a struct this way? Is there an alternative way, if not?
Thanks.
|
|
|
|