|
Hi
I have a listview on which I need to edit the subitem in a column in-place. A twist to the tail is that the specified column needs to be in edit mode whenever the list has focus (and that the list needs to be focussed when the dialog pops...)
This is on a modal dialog CAxDialogImpl. I use a CContainedWindow member variable (initialised as of type Edit in the constructor of the dialog class) to create a edit box, with the Listview as parent, and the subitems rectangle whenever the dialog signals edit mode (listview focussed and idle).
Problem is that my edit box displays - but fails to display a cursor of its text - untill the columnwidth gets narrowed and expanded by mouse drag!
Second Question: How to modify Listview row height programmatically?
Relevant sections of code:
*.h:
class CCashDlg :
public CAxDialogImpl<ccashdlg>
{
// Construction
public:
CContainedWindow m_cwEdit;
LRESULT OnEditKillFocus(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
void EditTenderAmount(LVITEM & lvItem);
CCashDlg(); // standard constructor
~CCashDlg(); // standard destructor
// Dialog Data
//{{AFX_DATA(CCashDlg)
enum { IDD = IDD_CASHDLG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
BEGIN_MSG_MAP(CCashDlg)
NOTIFY_HANDLER( IDC_EDIT_LBL, NM_KILLFOCUS, OnEditKillFocus)
REFLECT_NOTIFICATIONS()
ALT_MSG_MAP(1)
MESSAGE_HANDLER(WM_SETFOCUS, OnSetEditFocus)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
LRESULT OnSetEditFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
// Implementation
protected:
HWND m_HWNDEdit;
private:
//
};
//*.cpp
CCashDlg::CCashDlg() :
m_cwEdit(_T("Edit"), this, 1)
{
//{{AFX_DATA_INIT(CCashDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_HWNDEdit = 0;
}
void CCashDlg::EditTenderAmount(LVITEM & lvItem)
{
HWND hWndlist = GetDlgItem(IDC_LIST_SPLIT_CASH) ;
DWORD dwStyle = WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL |
ES_MULTILINE | ES_AUTOVSCROLL | WS_TABSTOP ;
//DWORD dwStyle = WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_TABSTOP|WS_BORDER|ES_LEFT;
DWORD dwExStyle = WS_EX_CLIENTEDGE;
if (m_Timer )
{
KillTimer( m_Timer);
m_Timer = 0;
}
RECT rectSub ;
BOOL bGetRect = ListView_GetSubItemRect(hWndlist, lvItem.iItem, 4,LVIR_BOUNDS, &rectSub );
if ( !(BOOL)m_HWNDEdit)
{
m_HWNDEdit = m_cwEdit.Create((HWND) hWndlist ,/*(RECT *) &*/ rectSub, /*(LPCTSTR)*/ "", (DWORD) dwStyle, (DWORD) dwExStyle ); //, (UINT ) NULL , (LPVOID) NULL) ;
ATLASSERT((BOOL) m_HWNDEdit );
TCHAR pszText[22] ;
::SetWindowText(m_HWNDEdit, "TEST" /*pszText*/);
//LONG_PTR lptrStyle = ::GetWindowLongPtr( m_HWNDEdit, GWL_STYLE );
//::SetWindowLongPtr( m_HWNDEdit, GWL_STYLE, lptrStyle | WS_VISIBLE ) ;
::PostMessage(m_HWNDEdit, WM_SHOWWINDOW, 1,0);
::PostMessage(m_HWNDEdit, WM_SETFOCUS, NULL, 0);
//::SetActiveWindow( m_HWNDEdit) ;
::PostMessage(m_HWNDEdit, EM_SETSEL, 0, -1);
}
else // we already have a window - just move it
{
::MoveWindow( m_HWNDEdit , rectSub.left , rectSub.top ,
rectSub.right - rectSub.left ,
rectSub.bottom - rectSub.top , TRUE);
//::SetWindowPos( HWND hWndInsertAfter,rectSub.left, rectSub.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW );
::PostMessage(m_HWNDEdit, WM_SHOWWINDOW, 1,0);
::PostMessage(m_HWNDEdit, WM_SETFOCUS, NULL, 0);
::PostMessage(m_HWNDEdit, EM_SETSEL, 0, -1);
}
}
What am I missing??
Any advice appreciated
JacquesJTheron
|
|
|
|
|
I seemed to have found the answer to the first question above - the message map to the setfocus of the dynamically created contained window edit box, has an out parameter called bHandled. It defaults to (BOOL) TRUE - and thus the normal setfocus process is not completed. If the notification changes this value to bHandled = FALSE, windows / atl handles the screen refreshing and adds a cursor, paints the text, etc.
Maybe this will help someone out their...
jacquesjtheron
|
|
|
|
|
I have built a interface as below:
HRESULT GetBSTR1([out,retval]BSTR* bstrInfo);
If VBScript call this component method the codes as below:
Set aaa = CreateObject("ATLTest.TestOne")
v1=aaa.GetBSTR1()
MsgBox v1
OK
and if I build my interface into
HRESULT GetBSTR2([out]BSTR* bufName1,[out,retval]BSTR* bufName2);
how the VBScript call this method
|
|
|
|
|
I Don't know about vbscript but in VB
Dim a As New TESTCOM1Lib.TestInterface
Dim str, str1 As String
str = a.GetBSTR2(str1)
MsgBox str1, vbOKOnly, str
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Sorry I haven't ever learned VB
Private Sub Form_Load()
Dim a As New ATLTESTLib.ITestTWO
Dim str, str1 As String
str = a.GetBSTR2(str1)
MsgBox str1, vbOKOnly, str
End Sub
Compile Error and My COM Interface Is:
interface ITestOne : IDispatch
{
[id(1), helpstring("method GetBSTR1")] HRESULT GetBSTR1([out,retval]BSTR*
bstrInfo);
[propget, id(2), helpstring("property property")] HRESULT property([out,
retval] long *pVal);
[propput, id(2), helpstring("property property")] HRESULT property([in] long
newVal);
};
[object,uuid(6FFD87E9-5733-4DF2-A33A-161D44FBC7D0),dual,helpstring("ITestTwo Interface"),pointer_default(unique)]
interface ITestTwo : IUnknown
{
[id(1), helpstring("method GetBSTR2")] HRESULT GetBSTR2([out]BSTR* bufName1,
[out,retval]BSTR* bufName2);
};
[uuid(D8F2F3E6-3356-437B-849D-087CCD9439F0),version(1.0),helpstring("ATLTest 1.0 Type Library")]
library ATLTESTLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(9072075F-656A-4B1C-9809-17A6164D1507),
helpstring("TestOne Class")
]
coclass TestOne
{
[default] interface ITestOne;
};
};
|
|
|
|
|
I haven't ever learned VB before,your codes are compiled and error happened
|
|
|
|
|
Wait i will send you code for both application
send me mail at alok@efextra.com
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
If I recall correctly, VBScript can't handle out-only parameters.
--
Weiter, weiter, ins verderben.
Wir müssen leben bis wir sterben.
I blog too now[^]
|
|
|
|
|
thanks for your answer.Do you mean VBScript can onle receive [out retval] parameter
|
|
|
|
|
It turns out that VBScript can do [out] parameters, but only if the type of the parameter is VARIANT, as this article[^] explains.
--
Weiter, weiter, ins verderben.
Wir müssen leben bis wir sterben.
I blog too now[^]
|
|
|
|
|
|
could I say that if I build a compnent used by VBScript and other script language,the parameter should be dedined VARIANT
|
|
|
|
|
For out-parameters, that is a good strategy I'd say, as script languages are often weakly typed.
--
Weiter, weiter, ins verderben.
Wir müssen leben bis wir sterben.
I blog too now[^]
|
|
|
|
|
Hello everybody.
After importing an ATL DLL in a mfc app
I want to use the Interface to use methods and
Others. OR I want to declare a variable from Interface to use .
Best Wishes,
Thanks.
|
|
|
|
|
Assuming you mean '#import' this will give you .tlh/.tli files.
These define wrapper classes (unless you use an option to switch these off) inside a namespace (unless you use an option to turn this off).
You need to declare an instance of one of the wrappers, use either raw CoCreateInstance or the wrapper's version to get the appropriate object instantiated and get back the interface. You can then use the methods via your object.
Typically, being retro, I use raw interfaces, and declare mine using
CComPtr<imyinterface> spObj;
but then, I'm old fashioned, I like to see error values myself, rather than having exceptions thrown.
Steve S
Developer for hire
|
|
|
|
|
|
Hi,
I'm not entirely sure whether the two things are related, but I'm pretty sure I've read articles here in the past on it but can't find them now.
Effectively I want to build a small app that will give me a text box and a button inside my taskbar that will link in to Google desktop, enabling me to put search items straight in without having to fire up IE first. Effectively it'll just launch IE with a particular URL, with the search terms I enter.
Anyway, I was wondering if anyone can point me in the right direction, or indeed let me know whether any such utilities already exist?
Thanks,
--
Paul
"Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office."
- David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk
Download my PGP public key
|
|
|
|
|
|
Great, thanks. Now I just have to set aside some time tonight and give it a go.
--
Paul
"Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office."
- David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk
Download my PGP public key
|
|
|
|
|
I want to change the Active Directory User's state icon. And I have added a new icon to user class, but I don't know how to set the current state to expect state.
example: If my icon state is 3, how to set the user state to 3?
|
|
|
|
|
I want to change the Active Directory User's state icon. And I have added a new icon to user class, but I don't know how to set the current state to expect state.
example: If my icon state is 3, how to set the user state to 3?
|
|
|
|
|
Hi Everybody
Does anybody know how to override the GetWindowProc method? I want to handle some specific messages in my own window procedure and direct the others to the base WndProc.
Regards Roozbeh.
|
|
|
|
|
1. You do not need to override GetWindowProc(), it can be done in the PreTranslateMessage() like so:
virtual BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_COMMAND)
OnCommand(true);
return FALSE;
}
2. If you still want to do it, here is an example how to override a GetDialogProc(), hope it's helpful:
DLGPROC CMyDlg::GetDialogProc()
{
return MyDialogProc;
}
INT_PTR CALLBACK CMyDlg::MyDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CNoteDlg * pThis = (CNoteDlg*)hWnd;
_ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
const _ATL_MSG* pOldMsg = pThis->m_pCurrentMsg;
pThis->m_pCurrentMsg = &msg;
LRESULT lRes;
BOOL bRet = pThis->ProcessWindowMessage(pThis->m_hWnd, uMsg, wParam,
lParam, lRes, 0);
if (DEFERDELETE == pThis->m_bAutoDelete && pOldMsg == NULL)
{
delete pThis;
return FALSE;
}
ATLASSERT(pThis->m_pCurrentMsg == &msg);
pThis->m_pCurrentMsg = pOldMsg;
if(bRet)
{
switch (uMsg)
{
case WM_COMPAREITEM:
case WM_VKEYTOITEM:
case WM_CHARTOITEM:
case WM_INITDIALOG:
case WM_QUERYDRAGICON:
case WM_CTLCOLORMSGBOX:
case WM_CTLCOLOREDIT:
case WM_CTLCOLORLISTBOX:
case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG:
case WM_CTLCOLORSCROLLBAR:
case WM_CTLCOLORSTATIC:
return lRes;
break;
}
::SetWindowLong(pThis->m_hWnd, DWL_MSGRESULT, lRes);
return TRUE;
}
if(uMsg == WM_NCDESTROY)
{
HWND hWnd = pThis->m_hWnd;
pThis->m_hWnd = NULL;
pThis->OnFinalMessage(hWnd);
if (pThis->m_bAutoDelete)
{
if (pThis->m_pCurrentMsg == NULL)
delete pThis;
else
pThis->m_bAutoDelete = DEFERDELETE;
}
}
return FALSE;
}
|
|
|
|
|
Thanks a lot for your help.
Regards Roozbeh.
|
|
|
|
|
Hi all !
I was assigned a task which I don't think is possible to do.
What I was requested to achieve is basically the following:
To cause our existing MFC (Doc/view) application to become a COM EXE server !
Is it possible at all, or am I wasting my time. If it's not possible, what approach shall I take?
I used the information which appeared under the article :
Article ID :175190
Last Review:June 29, 2004
Title : How to add ATL support to an MFC EXE
Link : http://support.microsoft.com/default.aspx?scid=kb;EN-US;175190[^]
Outcome so far : NOT Successful, meaning, the registration is not failing, but the server cannot be found by a client application (class not registered !)
As far as I understand , the article 175190 discusses the option of
embedding an "local In-process COM server" into the application, not a "remote COM EXE server".
I tried everything I know, so far with no results..
Please help,
Rubi
|
|
|
|
|