|
|
When using MFC, we can create dll usign MFC, and create MFC dialog or MFC windows in DLL. And Shows the dialog or windows by export functions.
But how to use WTL in dll? WTL AppWizard can only create exe project, ATL has no enough UI support. What can we do to usign WTL in dll? Create WTL dialogs and WTL windows and other WTL UI components.
Thanks
|
|
|
|
|
Hi,
tank0 wrote: What can we do to usign WTL in dll?
WTL is a template library and as you certainly know templates are compiled when used, not when declared. Thus it is impossible to export uninstanciated template classes from a dll.
That said, you can use WTL in dlls which export only fully instanciated templates like WTL_DLL.ZIP
in the Files section of the WTL support list[^].
Another example is here[^].
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Alain Rist wrote: WTL is a template library and as you certainly know templates are compiled when used, not when declared. Thus it is impossible to export uninstanciated template classes from a dll.
That said, you can use WTL in dlls which export only fully instanciated templates like WTL_DLL.ZIP in the Files section of the WTL support list[^].
Another example is here[^].
cheers,
AR
Thanks for your reply. What I what to do is just like you said.
Export a single function in the dll such as ShowDlg()
What the ShowDlg function do is that creates a modal window and shows.
With MFC, I can just create a "Regular DLL with MFC statically linked" project and in the project use codes like below is enough.
But I don't know what to do with WTL. WTL appwizard can only create exe projects.
extern "C" __declspec(dllexport) void ShowDlg()
{
CDialog dlg(IDD_Dialog1);
dlg.DoModal();
}
|
|
|
|
|
Use an AppWiz generated Win32 dll with the code from a WTL application. Study the referenced WTL_DLL.ZIP code, it's really simple and does exactly what you wish
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
I got it, thanks for your help
|
|
|
|
|
You are welcome
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Hi ,
I am creating BHO component in which I used DWebBrowserEvents2 interface and overrides its
OnQuit() function. When i test this function on IE8 on Vista, it called on my machine but does not called on other machine with same configuration. What may be the problem for not calling onQuit() function on other machine.
Does this mean that IE8 is not installed properly on other machine, or there is need to installed windows update for this.
please let me know how IE8 behavior change from machine to machine.
Thanks
Atul
|
|
|
|
|
Documentation states OnQuit 'Fires before the Windows Internet Explorer application quits'. May be you can check if the IE has actually quit.
|
|
|
|
|
I am writing an application wherein I need to scan the computer to see if either of two different USB devices are attached. The first device appears as a HID, and the second device appears as a virtual COM port. Which WMI classes should I be checking to see if each device is attached?
I am using this for the HID:
m_bstrScope = SysAllocString( _T("root\\CIMV2") );
m_bstrQuery = SysAllocString( _T("SELECT PNPDeviceID FROM Win32_PnPEntity") );
...and this for the virtual COM port device:
m_bstrScope = SysAllocString( _T("root\\CIMV2") );
m_bstrQuery = SysAllocString( _T("SELECT DeviceID,PNPDeviceID FROM Win32_SerialPort") );
This pseudo code shows how my scanning algorithm works:
if ( ScanForDevice1() )
{
}
else if ( ScanForDevice2() )
{
}
else
{
}
This seems to work, except when I change which device is connected between running the application. If device 1 is found, the scan for device 2 is aborted; the scan for device 2 only occurs if device 1 is not found. What happens is this:
- The application is run with both devices attached to the system. Device 1 is found, as expected. The application exits.
- Device 1 is unplugged from the system.
- The application is run with only device 2 attached to the system. Oddly, device 1 is found, even though it is not attached. The application exits.
- Both devices are unplugged from the system.
- The application is run with no devices attached. No devices are found, as expected. The application exits.
- Only device 2 is plugged back into the system.
- The application is run with only device 2 attached. The application finds device 2, as expected.
My best guess is that I am querying the wrong class(es). Which classes should my application be checking? Or, is there something else that I should be doing? Thanks.
|
|
|
|
|
one com interface function :
class IProtocolImp : public IUnknown
{
.....
GetRegisters( char *szDeviceName[int], LPVOID *ppReg[out] , int *pRegNum[out] );
// Get registers name and number
......
}
typedef struct reginfo
{
char sRegName[8];//register's name
int nLowIndex;
int nUpperIndex;
WORD wDataType;//
int nData;
}REG_INFO;
i call this in my project,
IProtocolImp * pf;
int RegNum;
REG_INFO * BASED_CODE pRegInfos[256];
HRESULT res=::CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,IID_ProtocolImp,(void * *)&pf);
if(res == S_OK)
{
pf->GetRegisters("MyDevice",(LPVOID *)pRegInfos,&RegNum);
}
if program is correct,will return
RegNum=2;
gsRegInfos[0]={"DATA1", 0, 15, 100, 0};gsRegInfos[1]={"DATA2", 0, 15, 100,0};
but program has a problem,
RegNum=2;//this correct
gsRegInfos[0]={"DATA1", 0, 15, 100, 0};gsRegInfos[1]=0xcccccccc;//this a problem
why ????
it is com code:
"xxx.h"
static REG_INFO BASED_CODE gsRegInfos[]=
{
{"DATA1", 0, 15, 100, 0};
{"DATA2", 0, 15, 100, 0};
};
"xxx.cpp"
STDMETHODIMP_(BOOL) MYDLLPro::XProtocolImp::GetRegisters(char *szDeviceName,LPVOID * ppRegs, int *pRegNum)
{
METHOD_PROLOGUE(MYDLLPro, ProtocolImp);
*ppRegs = (LPVOID)&gsRegInfos;
*pRegNum = sizeof(gsRegInfos)/sizeof REG_INFO;//REG_TYPE_NUM
return TRUE;
}
|
|
|
|
|
It's not easy to read your question. Please edit the message and put <pre></pre> tags around he code blocks so they can be read more easily. From a quick glance it looks like your indexing is not working properly, check the pointer indexing in your GetRegisters() function.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Perhaps if you formatted your code so it's readable?
Steve
|
|
|
|
|
I'm a new one, which want to learn linux. but i do't how to study it.
i have use ubuntu some days.but i find i use it like windows. i don't
understand somethings about linux,but just use g++.
I want to be a coder in linux, so give me some advices , thank you very
much
|
|
|
|
|
Here, perhaps this will get you started: Programming for Linux[^]
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
In my current VS C++ app I create an fstream log file for output and all works fine. It's initialized in the constructor declaration. Now I want to close it and start a new one upon the log file reaching a size limit. I've tried a number of things with no success. One approach was to not initialize in the constructor and use .open. That didn't work. Another was to go back to initialize in the constructor, then close, and rename, and open again. That didn't work either. Either I am missing some key point here or just doing some samll thing incorrectly. Any help would be appreciated.
Thanks
|
|
|
|
|
Alan Kurlansky wrote: That didn't work.
This sort of statement is really not very helpful; nobody can guess why it did not work. Explain exactly what you did and what results you got, if there is a short code snippet that helps with the explanation then include that as well. And don't forget to put code between <pre></pre> tags.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Sorry about that. But I was able to get things to work by reducing the scope of the file management. Now I am opening, closing, renaming the file all from within a function, using all local and local static variables.
|
|
|
|
|
Why "FlatSB" is useless in WTL?
::InitializeFlatSB,::FlatSB_EnableScrollBar,::FlatSB_SetScrollProp...return 0.
Create a Dialog(or Edit Control、List Control...),
Set show HorizontalScrollBar and VerticalScrollBar,
in OnInitDialog(...):
BOOL bRet = ::InitializeFlatSB(m_hWnd);
bRet = ::FlatSB_EnableScrollBar(m_hWnd,SB_BOTH,ESB_ENABLE_BOTH);
bRet = ::FlatSB_SetScrollProp(m_hWnd, WSB_PROP_VSTYLE, FSB_FLAT_MODE, TRUE);
bRet = ::FlatSB_SetScrollProp(m_hWnd, WSB_PROP_HSTYLE, FSB_FLAT_MODE, TRUE);
// change scrollbar color
bRet = ::FlatSB_SetScrollProp(m_hWnd, WSB_PROP_HBKGCOLOR, 0x008000ff, TRUE);
bRet = ::FlatSB_SetScrollProp(m_hWnd, WSB_PROP_VBKGCOLOR, 0x0000ff80, TRUE);
this works on MFC!
|
|
|
|
|
Hi,
dancingfish wrote: Why "FlatSB" is useless in WTL?
WTL support for flat scroll bars in atlctrls.h:
#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
template <class T>
class CFlatScrollBarImpl
{
template <class TBase>
class CFlatScrollBarT : public TBase, public CFlatScrollBarImpl<CFlatScrollBarT< TBase > >
{
typedef CFlatScrollBarT<ATL::CWindow> CFlatScrollBar;
As Comctl32.dll versions 6.00 and later do not support flat scroll bars check (WTL::RunTimeHelper::IsCommCtrl6() == false) before use
cheers,
AR
Edit: Added CommCtrl version check suggestion.
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Wednesday, November 10, 2010 5:15 AM
|
|
|
|
|
hi
I know the class CFlatScrollBarImpl, i've got a failed try, so i directly call these APIs(::InitializeFlatSB,::FlatSB_EnableScrollBar,::FlatSB_SetScrollProp...), but still same problem.
BOOL bRet;
bRet = ::InitializeFlatSB(m_hWnd);
bRet = ::FlatSB_EnableScrollBar(m_hWnd,SB_BOTH,ESB_ENABLE_BOTH); // bRet = 0
bRet = ::FlatSB_SetScrollProp(m_hWnd, WSB_PROP_VSTYLE, FSB_FLAT_MODE, TRUE);
bRet = ::FlatSB_SetScrollProp(m_hWnd, WSB_PROP_HSTYLE, FSB_FLAT_MODE, TRUE);
bRet = ::FlatSB_SetScrollProp(m_hWnd, WSB_PROP_HBKGCOLOR, 0x6fa1d9, TRUE);
bRet = ::FlatSB_SetScrollProp(m_hWnd, WSB_PROP_VBKGCOLOR, 0x00ff00, TRUE);
or
private:
CFlatScrollBar* m_pScrollbarFlat;
m_pScrollbarFlat= new CFlatScrollBar(m_hWnd);
bRet = m_pScrollbarFlat->FlatSB_Initialize();
bRet = m_pScrollbarFlat->FlatSB_EnableScrollBar(SB_BOTH); // bRet = 0
bRet = m_pScrollbarFlat->FlatSB_SetScrollProp(WSB_PROP_VSTYLE, FSB_FLAT_MODE, TRUE);
bRet = m_pScrollbarFlat->FlatSB_SetScrollProp(WSB_PROP_HSTYLE, FSB_FLAT_MODE, TRUE);
bRet = m_pScrollbarFlat->FlatSB_SetScrollProp(WSB_PROP_HBKGCOLOR, 0x6fa1d9, TRUE);
bRet = m_pScrollbarFlat->FlatSB_SetScrollProp(WSB_PROP_VBKGCOLOR, 0x00ff00, TRUE);
bRet return 0 on "FlatSB_EnableScrollBar".
it works in MFC.
I don't know what's wrong with this.
|
|
|
|
|
Hi,
dancingfish wrote: I know the class CFlatScrollBarImpl, i've got a failed try
As you don't explain what you tried and what you mean by failed it is difficult to help you.
Use WTL::CFlatScrollBar this way:
class CFlatScrollBarWnd : public CWindowImpl<CFlatScrollBarWnd, CFlatScrollBar>
{
public:
DECLARE_WND_CLASS(NULL)
BEGIN_MSG_MAP(CFlatScrollBarWnd)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
END_MSG_MAP()
LRESULT OnCreate(UINT , WPARAM , LPARAM , BOOL& )
{
FlatSB_Initialize();
FlatSB_SetScrollProp(WSB_PROP_VSTYLE, FSB_ENCARTA_MODE);
FlatSB_ShowScrollBar(SB_BOTH);
FlatSB_SetScrollRange(SB_HORZ, 0, 2000);
FlatSB_SetScrollRange(SB_HORZ, 0, 1000);
return 0;
}
};
Remember that the Flat SB control is not supported on WinXP and later, so nothing happens there.
Good luck,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
"Remember that the Flat SB control is not supported on WinXP and later, so nothing happens there."
but the Flat Scrollbar is shown in MFC.(::InitializeFlatSB,::FlatSB_EnableScrollBar,::FlatSB_SetScrollProp... all return 1)
Maybe this is the point!("not supported on WinXP and later" just in WTL? i can't understand this.)
my OS is Windows XP.
I just try to show Flat Scrollbar, but ::FlatSB_EnableScrollBar return 0 however i do in WTL.
|
|
|
|
|
To have it working on XP remove the manifest from the executable, and indeed it is supported.
You may check it this way:
With the WTL AppWizard create a FlatScrollBar project with all default selections.
Change FlatScrollBarView.h to:
#pragma once
class CFlatScrollBarView :
public CWindowImpl<CFlatScrollBarView, CFlatScrollBar>
{
public:
DECLARE_WND_CLASS(NULL)
BEGIN_MSG_MAP(CFlatScrollBarView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
END_MSG_MAP()
LRESULT OnCreate(UINT , WPARAM , LPARAM , BOOL& )
{
FlatSB_Initialize();
FlatSB_SetScrollProp(WSB_PROP_VSTYLE, FSB_ENCARTA_MODE);
FlatSB_SetScrollProp(WSB_PROP_CXVSCROLL, 100);
FlatSB_SetScrollProp(WSB_PROP_HBKGCOLOR, RGB(0x80, 0, 0x80));
FlatSB_ShowScrollBar(SB_BOTH);
FlatSB_SetScrollRange(SB_HORZ, 0, 2000);
FlatSB_SetScrollRange(SB_HORZ, 0, 1000);
return 0;
}
LRESULT OnDestroy(UINT , WPARAM , LPARAM , BOOL& )
{
FlatSB_Uninitialize();
return 0;
}
};
In (VS2008) Project->FlatScrollBar Properties->Manifest Tool->Input and Output Set Embed Manifest to No.
Compile and run under XP, you will get a flat SB
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Friday, November 12, 2010 5:39 AM
|
|
|
|
|
Dear CodeProject
I'm developing an OLE DB Provider using Microsoft OLE DB Provider templates.
I have some problems with this project when I want to add bookmark capability to it.
My question:
Is it necessary to include bookmark column in column rowset schema in session object?I mean when we popultae rowset with information of columns of a table,should we add a record for bookmark (specially for a self bookmark with orddinal 0)?
Thank you very much
Reza As'adi
mreza_asadii@yahoo.com
|
|
|
|
|