|
I have created a button with a drop down arrrow with the following code:
<br />
TBBUTTON Button;<br />
TCHAR* pButSearchCaption = _T("Search Web");<br />
int iIndex0 = ::SendMessage(m_hWnd, TB_ADDSTRING, 0, (LPARAM)pButSearchCaption);<br />
Button.fsState = TBSTATE_ENABLED;<br />
Button.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE | TBSTYLE_DROPDOWN; <br />
Button.dwData = 0;<br />
Button.iString = iIndex0;<br />
Button.iBitmap = I_IMAGENONE;<br />
::SendMessage(m_hWnd, TB_INSERTBUTTON, 0, (LPARAM)&Button);<br />
I then add the following code to my message map to handle the TBN_DROPDOWN handler:
<br />
BEGIN_MSG_MAP(CMFToolbar)<br />
MESSAGE_HANDLER(WM_CREATE, OnCreate)<br />
MESSAGE_HANDLER(WM_SIZE, OnSize)<br />
ALT_MSG_MAP(1)<br />
NOTIFY_CODE_HANDLER(TBN_DROPDOWN, OnButDropDown)<br />
END_MSG_MAP()<br />
<br />
LRESULT OnButDropDown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);<br />
However, whenever I click the arrown on the button, it seems as the OnButDropDown isn't being called. Anyone know why this is.
|
|
|
|
|
WM_NOTIFY messages are sent to the toolbar's parent window, just like with all child controls. You need to handle TBN_DROPDOWN in the parent and reflect it back to the toolbar.
Also, your TB_ADDSTRING call is wrong, you need to pass a double-null-terminated string.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
how can i use CString with ATL in Visual Studio .NET?
|
|
|
|
|
Avi Laviad wrote:
how can i use CString with ATL in Visual Studio .NET?
#include <atlstr.h> ... to use ATL::CString
or
#include <atlmisc.h> ... to use WTL::CString
Greetings, Ralph
|
|
|
|
|
Ralph Wetzel wrote:
#include <atlstr.h> ... to use ATL::CString
#include <atlmisc.h> ... to use WTL::CString
I Couldn't find these two file in both of my compiler i.e. Visual Studio 6.0 and Visual Studio .Net.
Could you please tell how to use this two class.
thanks
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
You need atlmisc.h which comes with the other WTL headers you have to download from microsoft.
Then you need to define _WTL_USE_CSTRING to forward declare the CString class.
Look at the Beginner WTL tutorials here at codeproject (for example WTL for MFC programmers Part II covers including CString right at the beginning)
--Constantin
|
|
|
|
|
i am extremly thankful to u!
Thanks once again.
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
|
hi,
i added a custom resource to visual studio and im trying to do FindResource()
but it always return me null.
<br />
FindResource(_AtlModule.GetResourceInstance(), Xi_Name, "TEMPLATES");<br />
anyone know's whatsmy problem?
|
|
|
|
|
i have a OCX made in VB
when used in VB it has a function
func1( t1 as Integer, t2 as Integer)
if i use this OCX in MFC ( import )
the func ends up like
func1(short * t1,short * t2);
the func works fine in vb
but if i call it from MFC using short *
it doesn't work i tried passing short * and variants with integers and other stuff but no luck
how should i call it, why is there short * but just an integer in VB
please help
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
short x = 1234;
short y = 5678;
func1(&x, &y); It looks like VB defaults to pass by reference. Try modifying the VB function to "func1(t1 as ByVal Integer, t2 as ByVal Integer)" and see if what happens in the generated C++ source.
--
My name in Katakana is ヨレゲン.
My name in German is Jörgen.
I blog too now[^]
|
|
|
|
|
Jörgen Sigvardsson wrote:
short x = 1234;short y = 5678;func1(&x, &y);
yes tried that doesn't work
unfortunatly i don't have the source code for the vb dll
the above stuff should but it doesn't
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
How to use FindResourceEx for multiple dialog resources for different languages.
|
|
|
|
|
hi,
im coding an Add-In (Visual C++) that do some changes to the document files in Visual Studio (.NET).
in the code i need to get the Active Project that in the solution explorer (the one that will run when the project is execute).
how can i do that?
in MFC i think , in the class IApplication, there's ->get_ActiveProject,
but in the classes of EnvDTE there's not (i didn't find).
does anyone know about something like that? or is there another way to know which is the active/startup project?
thanks in advance,
Avi.
|
|
|
|
|
Looking at a (good) sample add-in that comes with source code(Fast Solution Build by Joshua Jensen[^]), it looks like:
The DTE has a property called Solution, which has a property called SolutionBuild, which has a property called StartupProjects. This is the list of startup projects for the solution.
HTH!
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
|
Hallo,
I’m facing a winlogon/Notify problem.
I’m creating to Winlogon Notification Package. I have therefore written an ATL DLL with a winlogonevent handler function. I exported the winlogon event handler function with the “MyProjectName.def” file as follows
LIBRARY "MyProjectNamaePS"
EXPORTS
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
GetProxyDllInfo PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
fLogonEventHandler PRIVATE
fLogoutEventHandler PRIVATE
From the fLogonEventHandler function I’m doing the following things
void fLogonEventHandler (PWLX_NOTIFICATION_INFO pInfo)
{
LPCTSTR lpTestValue;
HKEY hk;
DWORD dwData, dwDisp;
TCHAR BufSubkey[MAX_PATH];
LPTSTR MyTestValue;
long HRESULT;
BOOL BRESULT = 0;
LPCTSTR lpCaption;
TCHAR msg[128];
lpCaption = TEXT("OK");
wsprintf(msg, "It's OK!");
MessageBox(NULL, msg, lpCaption, MB_OK);
dwData = 1;
MyTestValue = TEXT("Test Value\n");
wsprintf(BufSubkey,"MyTESTCONTROL"\\TEST");
HRESULT = -1;
HRESULT = RegCreateKeyEx(HKEY_CURRENT_USER,
BufSubkey,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL,
&hk,
&dwDisp);
if (HRESULT == ERROR_SUCCESS)
{
HRESULT = RegSetValueEx(hk,
MTestValue,
0,
REG_DWORD,
(LPBYTE)&dwData,
sizeof(DWORD));
}
}
I registered the dynamic library on a terminal server and used Regmon.exe and filemon.exe to monitor the logon event on the server, and I created the registry entries inside the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\MyProjectname" subkey to register my dll.
Asynchronous = REG_DWORD 1
DllName = REG_SZ MyProjectname.dll
Impersonate = REG_DWORD 0
Logon = REG_SZ fLogonEventHandler
It appeared that the library was called at logon. But I did not seen the massage box and the user did not had in his registry the entry as it has to be.
Can anyone point me please to what I’m doing wrong?
Thanks a lot for your help.
dabayi
|
|
|
|
|
Never did the Winlogon packages, but I would say, that the messagebox is displayed on another console. And because it's waiting for OK clicking, the registry writing code is never executed.
|
|
|
|
|
Thanks a lot for your answer. It think also that the messagebox is displayed in another console. But nothing is also happened when I write the registry entries before call the messagebox. I things I have first to log on the user and then create a process with his tokon.
I will appreciate any help in this direction.
dabayi
|
|
|
|
|
Ah sorry, didn't checked the code behind the MsgBox
Yes, you're right - you cannot write to the registry as it is. That's because your'e trying to write to HKCU which is impossible in the current situation - there's no current user in context of winlogon package. You might try to use the HKCR or HKLM -that should work.
|
|
|
|
|
Thanks a lot for your help geo_m.
I get it. The problem was that I forgot to use __stdcall option to declare the exported functions.
A last question. Do u have an idea how to pass an nt service parameters?
Thanks
|
|
|
|
|
I see. For my info, writing to HKCU works in that situation?
Regarding your last question, AFAIK parameters are passed to a service just as they are to any C program. For the service, use the ServiceMain function that
you specified for your service. It has two parameters - argc and argv :
void WINAPI MyServiceMain(DWORD argc, TCHAR* argv[])
{
}
This is the same as main() in a C program:
- argc is the number of arguments.
- argv is an array of strings containing the service name and the parameters.
|
|
|
|
|
Does anyone know if there is a similar function to EscapeToCString in WTL? I have XML as a string and need to make sure that problem characters ('&', '<', '>', etc.) are converted before sending as part of a URL. My MFC version used EscapeToCString to do this, but now that we have converted to WTL, I have not been able to find anything to replace it with.
<small>Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that ...
Author: George Carlin
</small>
|
|
|
|
|
showe wrote:
Does anyone know if there is a similar function to EscapeToCString in WTL?
Not that I know of. But you can easily port the function into using ATL's CString as it's the same string as in MFC.
If you are using VC6 (and ATL3), you can use WTL's version of CString which is compatible with MFC's implementation.
--
My name in Katakana is ヨレゲン.
My name in German is Jörgen.
I blog too now[^]
|
|
|
|
|
Isn't EscapeToCString part of ATL Server??? (yes, it's in atlisapi.h) In which case, can't you use that version? (I'm presuming you're using VC++.NET!)
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|