|
Hi,
I would like to respond to the message WM_DRAWITEM within a CFrameWnd derrived Class. Unfortuanetly it doesn't appear within the list provide by class wizzard.
I want to use this message, to support an owner drawn CListCtrl.
Can anyone offer me any advice?
Cheers
Rich
|
|
|
|
|
If you plan to host your control in any CWnd-derived class, there's no need to handle WM_DRAWITEM in the parent. Just override CListCtrl::DrawItem in CYourListCtrl and MFC magic will work for you.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have created an Dialog-based MFC .exe Application and was wondering how to add a menu to the dialog box. I have found and used code adding toolbars and statusbars to dialog boxes successfully.
|
|
|
|
|
Create a menu. Right-click on your dialog box. Select Properties. You will see Menu: combobox. Select ID of your menu.
That's all
Jerzy
|
|
|
|
|
I want to know if it is possible to make a cell in a list control "span" both rows and columns (separately). I also want to change the font/orientation of text in a cell.
My request:
I want my list control to have visual highlights such as a whole row (item) be highlighted to show a visual break in the list - such as a grey block that spans all my columns and contains nothing.
I also want my list control to have a side-bar column that can have text displayed vertically to span a block of rows (items) - such as to indicate a block of related items.
In crude ASCII, I want something that looks like below (4 columns, XXX=grey blocks)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
P Last Name: First Name: MI:
e Address: City: State:
r Zip Code: Phone (H): Phone (W):
s
o
n
a
l
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
O Item 1: Price: Quantity:
r Item 2: Price: Quantity:
d Item 3: Price: Quantity:
e Item 4: Price: Quantity:
r Total Price: Total Items:
s
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Thanks all.
Johnny
|
|
|
|
|
You could achieve this with so-called custom draw, but I think you should switch to some grid control. There's one here on CodeProject; have a look in the Controls/Miscellaneous section.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Does each application have it's own message queue? Or is it one shared queue.
The VB function DoEvents()
and the C++ code
MSG msg;
while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&msg) ;
DispatchMessage(&msg);
}
Would indicate that there is one queue.
Philip McGahan
|
|
|
|
|
Each thread that creates a window is allotted its own message queue, and must include a message pump like the one you've litsed in order to process messages for that thread.
Think thread, not application. Here's a snip from the "Multiple Threads in the User Interface" article in the MSDN:
Changes to the Message Loop
"Applications with multiple threads must include a message loop in each thread that creates a window. The message loop and window procedure for a window must be processed by the thread that created the window. If the message loop does not reside in the same thread that created the window, the DispatchMessage function will not get messages for the window. As a result, the window will appear but won't show activation and won't repaint, be moved, receive mouse messages, or generally work as you expect it to."
later... as usual...
Hmmm - maybe this is more helpful - from the PSDK docs on windowing and messages:
"The system maintains a single system message queue and one thread-specific message queue for each GUI thread. To avoid the overhead of creating a message queue for non-GUI threads, all threads are created initially without a message queue. The system creates a thread-specific message queue only when the thread makes its first call to one of the Win32 User or GDI functions."
|
|
|
|
|
Thank you.
That was very informative.
|
|
|
|
|
Has anyone here ever seen this error.
"fatal error C1084: Cannot read type library file: 'TLBs\astm.tlb': Error loading type library/DLL."
I really have no idea what is going on. I get that when doing a regual #import statement. We designed the TLB. The tlb file was just compiled with no errors. It isn't a sharing violation since i made a complete copy of the file just for use in this application. The TLB file comes from a ATL/COM project. (note: I have also posted this in the COM forum: Didn't really know where it belonged.) If anyone has seen this and knows whats going on please help. I have tried everything i can think of. There doesn't seem to be much of anything on the internet about it and there is NOTHING of MSDN about it.
Any help is greatly appreciated.
Joseph Dempsey
jdempsey@cox.rr.com
Joseph.Dempsey@thermobio.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
Hello.
I am developing a project that includes a Dialog containing a CTreeCtrl object.
When running my application in a WindowsNT machine and i display the Dialog i can see correctly the CTreeCtrl.
But when i run my application in a Windows98 machine when i display the Dialog if i don´t click on the CTreeCtrl i can´t see it.
Could you help me?.
Thanks in advance
Yolanda
|
|
|
|
|
Is there a possibility to clear the output window content from C++ code ?
|
|
|
|
|
Yes. IIRC WndTabs (wndtabs.com and article(s) here at CodeProject) has complete access to the IDE.
|
|
|
|
|
Hi,
This is the code I use, the error occurs at line "delete [] helper", but why??
LPWSTR helper = new WCHAR[cchBufferSize+28];
...
...
delete [] helper; <-----here is the debug assert!
One more question: I'm working the first time with unicode strings and functions like wcs****
Will my app work in every microsoft OS or only on NT/2000?
|
|
|
|
|
I need to see the rest of the code.
Specially this part:
some string manipulations like wcsncpy and so on...
Cheers!!!
Carlos Antollini.
|
|
|
|
|
here is the complete code, hth:
LPWSTR wszURL = new WCHAR[cchBufferSize];
LPWSTR helper = new WCHAR[cchBufferSize+28];
helper = wcsrev(wszURL);
int len = wcslen(helper)-2;
wcsncpy(wszURL,helper,len);
helper = wcsrev(wszURL);
wcscpy(wszURL,helper);
wcsncat(wszURL, lpwszSearchURL, cchBufferSize);
ZeroMemory(lpwszSearchURL, wcslen(wszURL));
wcsncpy( lpwszSearchURL, wszURL, cchBufferSize);
delete [] wszURL;
delete [] helper;
|
|
|
|
|
Just hazarding a guess here, but I think your assignment to 'helper' on the line
helper = wcsrev(wszURL); are the cause of the difficulty. After this line I don't think helper points to the memory that was originally allocated.
Chris Meech
|
|
|
|
|
Hello All,
I need C++ classes for doing basic statistics-preferable a template based one!
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 mean basic mathematical statistics.
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!
|
|
|
|
|
Delphi can not use my lib file so how can I provide dll that I write in vc++ to client that works in Delphi ????
|
|
|
|
|
Is your DLL exporting C style functions or C++ classes?
Michael
|
|
|
|
|
I'm still working through the whole connection point fiasco, with mixed results. OK, I admit it, they aren't mixed, it all blows. I've done a *lot* of reading and at this point I am pretty confident that my connection point is set up properly on the ATL side. I added the IDL manually, like this:
interface ISAFileDB : IDispatch
{
[id(1), helpstring("method Connect")] HRESULT Connect([in] BSTR DatabasePath);
[id(2), helpstring("method CloseDB")] HRESULT CloseDB();
[id(3), helpstring("method ScanDir")] HRESULT ScanDir([in] BSTR dir, [in] BSTR substr, [in] BSTR suffix, [out] IEnumSAFileEntry ** Entered, [out] IEnumSAFileEntry ** Changed, [out] IEnumSAFileEntry ** Skipped);
[id(4), helpstring("method GetDatabase")] HRESULT GetDatabase([out] IEnumSAFileEntry ** Database);
[id(5), helpstring("method SearchDatabase")] HRESULT SearchDatabase([in] BSTR substr, [in] BSTR suffix, [out] IEnumSAFileEntry **Database);
[id(6), helpstring("method DeleteRecords")] HRESULT DeleteRecords([in] BSTR substr, [in] BSTR suffix, [in] BOOL bDelete, [out] IEnumSAFileEntry **Deleted);
[id(7), helpstring("method VerifyDB")] HRESULT VerifyDB([in] BOOL bDelete, [out] IEnumSAFileEntry **Deleted);
[id(8), helpstring("method DoTest")] HRESULT DoTest();
};
[
uuid(224F8579-E559-436C-9FDD-D0CC70E6E013),
version(1.0),
helpstring("SADatabase 1.0 Type Library")
]
interface ISAFileDBEvents : IDispatch
{
[helpstring("method OnTest")] HRESULT OnTest();
};
[
uuid(95B90562-7A7E-4f61-8FE1-D0BB9548294A),
version (1.0),
helpstring("SAFileDBEvents 1.0 Type Library")
]
library SADATABASELib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(2CADF3A1-A5C9-4D89-A8ED-BEA59BDE6857),
helpstring("SAFileDB Class")
]
coclass SAFileDB
{
[default] interface ISAFileDB;
[default, source] interface ISAFileDBEvents;
};
[
uuid(100F3513-A370-434C-AD21-274AF9F3614E),
helpstring("SAFileEntry Class")
]
Then I added a method called DoTest to the ISAFileDB interface, and set up the connection point. I added code for a messagebox to DoTest, and left Fire_DoTest untouched.
Now on the MFC side I set up a class derived from CCmdTarget, like this:
class CConnPt : public CCmdTarget
{
DECLARE_DYNCREATE(CConnPt)
CConnPt();
public:
public:
public:
virtual void OnFinalRelease();
protected:
virtual ~CConnPt();
DECLARE_MESSAGE_MAP()
afx_msg void DoTest();
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
};
and in the .cpp file:
#import "..\ATL\SADatabase\SADatabase.tlb" no_namespace, named_guids
IMPLEMENT_DYNCREATE(CConnPt, CCmdTarget)
CConnPt::CConnPt()
{
EnableAutomation();
}
CConnPt::~CConnPt()
{
}
void CConnPt::OnFinalRelease()
{
CCmdTarget::OnFinalRelease();
}
BEGIN_MESSAGE_MAP(CConnPt, CCmdTarget)
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CConnPt, CCmdTarget)
DISP_FUNCTION(CConnPt, "Test", DoTest, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
static const IID IID_IConnPt =
{ 0xc3996b23, 0xcbce, 0x443f, { 0xb5, 0xd8, 0xa9, 0x8a, 0x9d, 0x1b, 0x62, 0xf1 } };
BEGIN_INTERFACE_MAP(CConnPt, CCmdTarget)
INTERFACE_PART(CConnPt, IID_ISAFileDB, Dispatch)
END_INTERFACE_MAP()
void CConnPt::DoTest()
{
AfxMessageBox("sdfsdf");
}
Now I do *this* when a button is pushed in the app
CoInitialize(NULL);
m_pConnPt = new CConnPt();
LPUNKNOWN pUnkSink = m_pConnPt->GetIDispatch(FALSE);
ISAFileDBPtr pIFind(__uuidof(SAFileDB));
IUnknown * pUnk = NULL;
pIFind->QueryInterface(IID_IUnknown, (void**)&pUnk);
AfxConnectionAdvise(pUnk, IID_ISAFileDBEvents, pUnkSink, FALSE, &m_dwCookie);
pIFind->DoTest();
AfxConnectionUnadvise(pUnk, IID_ISAFileDBEvents, pUnkSink, FALSE, m_dwCookie);
pUnk->Release();
CoUninitialize();
DoTest causes the dialog from the server to come up, but not the one in my CCmdTarget class, instead it crashes in comip.h, in the line:
void _Release() throw()
{
if (m_pInterface != NULL) {
m_pInterface->Release();
}
}
in the Release() call. The disturbing thing is if I trace it back it is the END of my function, when everything is going out of scope, indicating to me that I've got real problems, because by the time it crashes, the time for my connection point to work has well and truly passed.
Can *anyone* see what I am doing wrong and/or provide any advice ? The rest of this project came together like a dream, but the connection points have been an ongoing nightmare...
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Christian I mailing you *3* example sof connection points, all pretting darn basic, but illustrates how to implement connection points. The orthodox wat is to use dispinterface, but my examples shows you to use IUknown as well. Also there is an easier why to sink the connection end point again the examples will show you this.
I wrote a shed load of stuff (which I've lost) all about connection points. I'll have a look tonight and mail you if I can find the stuff.
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
Thanks a ton, Norm. I'll look forward to receiving them.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|