|
Don't know exactly if a c++ or com expert can help so I posted this in the com section, too.
I fill a pointer to a com object via CoCreateInstance. Now I use this one and must "get rid of" the connection and reinstanciate this object. Tried this via
Release() method, but this seems not to be enough. Any one an idea?
|
|
|
|
|
When you say its not enough, what exactly is happening.
I'm assuming the sequence you are going through is something like:
<br />
IMyInterface* pI = NULL;<br />
<br />
<font color=green>
HRESULT hr = ::CoCreateInstance(CLS_MyInterface, NULL, CLSCTX_INPROC_SERVER, IID_IMyInterface, (void**)&pI);<br />
if(FAILED(hr))<br />
return false; <font color=green></font><br />
<br />
<font color=green></font><br />
<br />
pI->Release();<br />
pI = NULL;<br />
<br />
<font color=green>
HRESULT hr = ::CoCreateInstance(CLS_MyInterface, NULL, CLX_INPROC_SERVER, IID_IMyInterface, (void**)&pI);<br />
<font color=gray><br />
..<br />
..</font><br />
I Dream of Absolute Zero
|
|
|
|
|
Thanks for the fast answer. What exactly happening is that a process started by the com object is still active in task manager and so it seems that the "release" from the com object is not completely enough to make the object usable again. If I call methods within the new instantiated com object they didn't work as expected. Killing the started process solves the problem. Could it be that the implementation of the com object itself has bugs and doesn't shutdown as expected if I release from the object? The developer says that setting the pointer to nothing and make a new instantiation works in VB 2003. Sorry if I write something that seems nonsense in com understanding, because in this field I'm a newbie.
|
|
|
|
|
MarcoNedwig wrote: "release" from the com object is not completely enough to make the object usable again.
Hmmm. Well in that case it sounds as if your COM does not allow, or does not work well with multiple instances. Maybe it is using a unique resource (the threading method used), that cannot be shared across several instances.
If that is the case, then you will need to ensure that all active processes are done before the component can be reused. If it is a feature then it should have been documented; if its a bug, then I hope you find a workaround
I Dream of Absolute Zero
|
|
|
|
|
I think so. Have a work-around killing a process and then it works but this can't be the correct thing. Thanks for showing me that it seems that I dont't made a mistake using the com object.
|
|
|
|
|
I have to write a module in VC++ which will enumerate all submenus within a menu.
I have successfully been able to enumerate all submenu items within each menu e.g WordPad. i get each submenu string using GetMenuString().
Now having got the submenu string i want to be able to launch each submenu window, e.g in Wordpad 'File' menu i need to launch the "Open" submenu which has the name "Open... Ctrl+O", i want to be able to launch it using the shortcut keys 'Ctrl+O' programatically. How do i do this?
This is a test application to enumerate all submenus and launch each submenu window using the short cut keys only.
Kindly suggest me a way to do, if a sample code exists kindly update.
Awaiting a response.
Sincerely
Giftsana
|
|
|
|
|
this is very simple. go to the Menu options and give "&" apersand at the beginning of the menu item which will be your required info.
cheers.
uday.
uday kiran
|
|
|
|
|
Hello Uday
Yes am aware of giving an '&' before the menu item for the shortcut key.
My problem is i need to launch e.g the 'Open' submenu window within 'File' menu which contains the string'Open... Ctrl+O' using only the shortcut key in this case 'Ctrl+O'.
I need to be able to launch the 'File' submenu window 'Open' using the shortcut key only.
Do u have an idea??
Giftsana
|
|
|
|
|
U need to add an accelerator for the menu item
go to resource view, open Accelerator folder, open IDR_MAINFRAME
accl. table there u specify id of ur menu item & the short cut key u want
& it's type should be VIRTKEY
|
|
|
|
|
Hi giftsana,
maybe it is some helpful to you
/////////Example CDialog//////////////
1from Add resource Insert a Accelerator(IDR_ACCELERATOR1)
2in the Accelerator ID Modifier Key Type
3 ID_FILE_OPEN Ctrl O VIRTKEY
(ID_FILE_OPEN here is same with declare ID in Menu(ID_FILE_OPEN)
4 then insert HACCEL m_haccel=LoadAccelerators(AfxGetApp()->m_hInstance,(LPCTSTR)IDR_ACCELERATOR1);
5 insert this function
BOOL CAnswer::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message>=WM_KEYFIRST&&pMsg->message<= WM_KEYLAST)
return TranslateAccelerator ( m_hWnd, m_haccel, pMsg );
return 0;
}
---------------------else CDialog--------------------------
my answer is same with thatsme_cool
ID item(Menu) in Accelerator is same with ID item in Menu
|
|
|
|
|
Hello
Thank you very much for the suggestion.
So this should help me to programatically open e.g. the 'Open' submenu window using the shortcut key 'Ctrl+O' right? likewise i should be able to open all other existing submenu windows with their shortcut keys programatically.
Thanks
Giftsana
|
|
|
|
|
Few years ago I took from CodeProject a Hyperlink class witch defines a IDC_HAND as MAKEINTRESOURCE(32649) and I don't known it's copyright author. Can you help me? I want to mentions his full name in my application. The header looks like this:
class CHyperlinkStatic : public CStatic
{
public:
CHyperlinkStatic();
public:
public:
protected:
virtual void PreSubclassWindow();
public:
virtual ~CHyperlinkStatic();
protected:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnPaint();
afx_msg void OnDestroy();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
public:
void SetHyperlink(CString strHyperlink);
void SetCaption(CString strCaption);
private:
CString _strCaption, _strHyperlink;
CFont _fontCaption;
CSize _sizeCaption;
bool _bCreateFont, _bMouseInControl, _bGetCaptionSize;
HCURSOR _hHandCursor, _hArrowCursor;
void CreateFont();
void GetCaptionSize();
bool InCaptionRange(CPoint &point);
}; (I might modified the class name and I don't known it's original name)
|
|
|
|
|
|
i have to develop a device driver for windows NT that will add a virtual audio device to the system. i need to hook up and capture the audio stream coming from microphone and send it to two differnt application. can anyone tell, is it possible or not?
if it is, where do i need to hook in the driver stack keeping in view that i can not replace miniport drivers.
is there any alternative to this
saad
-- modified at 5:21 Wednesday 12th April, 2006
|
|
|
|
|
I think a filter driver is what you need.
|
|
|
|
|
thank you kakan for helping me out
i have some Questions
can i show a separate virtual audio device with a filter driver?
2ndly we have different MSVAD drivers in DDK samples. are thay filter drivers?
can i use those sample codes for my work
saad
|
|
|
|
|
Hi All,
I am adding tooltip for a chart using CToolTipCtrl. No in-built method of chart drawing is used.
I am adding one column of chart as tool, but I cannot see the tooltip. When I tried to retrive the toolinfo again, the rectangle values are too different.
The code is like this.
CLineChart :: Create()
{
EnableToolTips(true);
mToolTip = new CToolTipCtrl();
mToolTip->Create(this);
}
CLineChart :: Draw()
{
CRect AreaValues; // This rectangle is determined to draw grid for chart
CString tText; // String to hold tool tip text
RECT tRect; // Tool rectangle
while adding columns (for c = 0 to 30)
{
tRect.top = AreaValues.top; // e.g. 8
tRect.bottom = AreaValues.bottom; // e.g. 182
tRect.left = AreaValues.left + column[c].start; // e.g. 8
tRect.right = tRect.left + column.width; // e.g. 50
tText = "Column No.";
mToolTip->AddTool(this, tText, &tRect, c+1);
mToolTip->Activate;
// After this I added code to check the values are set properly or not
CToolInfo ti;
mToolTip->GetToolInfo(ti, this, c+1);
// I checked rectangle and text values. Text values are proper.
// But for rectangle values w.r.t. above given example values I am
// getting something like this.
// ti.rect.top = 8
// ti.rect.bottom = 72
// ti.rect.left = 6
// ti.rect.right = 7
// And left and right values goes on decreasing even like -4, -5
}
}
Am I doing something wrong while adding tool? What can be the solution for this.
Thanks in advance.
Chioo.
Chioo.
|
|
|
|
|
I have troble in:
how to create scrollbar by the client rect?
how to adapt the scrollbar when the window's size changed?
my code:
int CDNAView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CRect crect;
GetClientRect(&crect);
VERIFY(m_scrollBar.Create(
SBS_VERT | SBS_RIGHTALIGN | WS_CHILD , CRect(0,0,756,429),this,10));// how to create scrollbar by the client rect?
m_scrollBar.ShowScrollBar();
return 0;
}
void CDNAView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
int lt,tp,rt,btm;
CRect rect;
GetClientRect(&rect);
lt = rect.left;
tp = rect.top;
rt = rect.right;
btm = rect.bottom;
m_scrollBar.MoveWindow(rt,tp,5,btm);// how to adapt the scrollbar when the window's size changed?
}
how to resove this question?
your kind reply will be appreciated greatly.
|
|
|
|
|
Hi LZL1010 ,
this code isnt good?
int CSDIView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_scrollBar.Create(
SB_VERT | SBS_RIGHTALIGN | WS_CHILD|WS_VISIBLE , CRect(0,0,556,309),this,10);
// how to create scrollbar by the client rect?
m_scrollBar.ShowScrollBar();
return 0;
}
void CSDIView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect rect;
m_scrollBar.GetClientRect(&rect);
rect.bottom=cy;
m_scrollBar.MoveWindow(&rect);// how to adapt the scrollbar when the window's }
}
|
|
|
|
|
your code is of a little problem.
when the size of the client area changed,the scrollbar should be redraw,because the position and the size of the scrollbar has been changed.your code redraw the scrollbar,but the size of the scrollbar doesn't change and the scrollbar lies to the left edge of the client.
because the data is too much.I draw at least 50000 lines on the view.
I want to implement it like the notepat . the notepad isn't a limit to the lines.
how to resolve this question?
|
|
|
|
|
LZL1010
I dont kown your code you write how to create scrollbar by the client rect
I insert a change to your code and if you need to left edge use rect.bottom=cy;rect.left=cx-15;rect.right=cx;
|
|
|
|
|
|
|
Hi Guys,
I'm creating one dll in MFC and compile by release mode. In my project I have used 3 global variables in stdafx.h file
global variables are
char *g_strename;
char *g_streid;
char *g_isalary;
Say file name: employee (DLL created using MFC appwizard DLL)when I compile my project it shows linker error messages & warning messages
StdAfx.obj : error LNK2005: "char * g_strename;(?g_strPassword@@3PADA) already defined in employee.obj
StdAfx.obj : error LNK2005: "char * g_streid@@3PADA) already defined in employee.obj
StdAfx.obj : error LNK2005: "int g_isalary;@@3HA) already defined in employee.obj
this is followed by LNK4006 warning message.
please help me out, to rectify this. Just quick will do be great.
Thanks
Vivek.S
You only have to do a very few things right in your life so long as you don't do too many things wrong.
|
|
|
|
|
vivek.s.vivek wrote: global variables are
char *g_strename;
char *g_streid;
char *g_isalary;
transfer these variable to a .cpp file and use
extern char *g_strename;
extern char *g_streid;
extern char *g_isalary;
in stdafx.h
|
|
|
|