|
In my code, I have created a Popup Menu containing a large number of menu items (does not fit in a single view). I display the same using TrackPopupMenuEX on the Menu handle.
The first time around when the Menu pops up, the the top most items of the menu are visible. Now if I scroll down the menu so that some other items are visible and close the menu in this state, the next time around when the same menu is popped up, the menu area and items visible is the same as When I had closed the menu in previous operation. The previous closing state of the menu is some how getting saved automatically.
I want to change this behavior. I want to change it such that the menu area visible on popup starts with the menu item I specify (either by Command ID or Position). Is this possible? How can I achieve it.
Thanks in advance..
P.A.Ajay Kumar M.Tech(IT) B.Tech(CS)
|
|
|
|
|
pa_ajaykumar wrote: I want to change this behavior
No, what you want to change is how you organise that popup's UI - think about your users - having a menu that large is insane.
Either categorise the menu entries by function type, or alphabetically, or something that makes sense, and then use those categories to populate sub-menus.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Well, the thing is that this pop-up menu is not going to be a right click context menu. Its a font selection menu which is going to be popped up over a button. Its bound to have so many items due to the number of fonts and the menu is already hierarchical (families as main menu items and styles as sub menu items). So further grouping is not an alternative.
P.A.Ajay Kumar M.Tech(IT) B.Tech(CS)
|
|
|
|
|
What's wrong with the standard font select dialog? Or grouping the fonts alphabetically (split fonts into groups starting with A-F, G-M, N-T, U-Z).
Anyway - the only way I know of to get the menu to forget it's selected location is to recreate it each time you show it.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi All,
I need to display a blinking cursor on the view but without using any control. How to do it?
Thanks
|
|
|
|
|
The blinking cursor is called a Caret and can be created using the CreateCaret function and shown using the ShowCaret function.
«_Superman_»
|
|
|
|
|
Hi Experts,
I have ATL DLL with Addition() method,
I calling this function from another MFC application with no argument
Code goes like :
Assume no syntax errors
CLSID cls_id;
CLSIDFromProgID(L"DLLTest.MyObject",&cls_id);
CComPtr<IDispatch> pService;
HRESULT hr = pService.CoCreateInstance(cls_id, NULL, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER);
if(hr == S_OK)
{
DISPID Disp_id;
CString bsvalue;
CComVariant Result;
OLECHAR *member=_T("Addition");
DISPPARAMS param = {NULL,NULL,0,0};
hr = pService->GetIDsOfNames(IID_NULL,&member,1,LOCALE_SYSTEM_DEFAULT,&Disp_id);
if(S_OK == hr)
hr = pService->Invoke(Disp_id,IID_NULL,LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD,¶m,&Result,NULL,NULL);
else
MessageBox(L"Could not get disp id",L"MSG",MB_OK);
}
else
MessageBox(L"No Interface",L"MSG",MB_OK);
This code works fine but,
now I want to call same function Addition() with two arguments, I have made respective chages in DLL, so please give me solution or hint
|
|
|
|
|
[Hint]If you post your code formatted in a <pre> block, we can read it easier, which means we're more likely to answer you question...[/Hint]
You want to add parameters to the param variable. They will be VARIANT s packaged as follows (note: I'm presuming they're 32-bit integer arguments, of value 12 and 45 respectively):
VARIANTARG args[2];
V_VT(&args[0]) = VT_I4;
V_I4(&args[0]) = 12;
V_VT(&args[1]) = VT_I4;
V_I4(&args[1]) = 45;
param.nArgs = 2;
param.rgvarg = args;
Add this code between a) declaring param and b) using param .
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am geting compile time error:
Error 1 error C2039: 'nArgs' : is not a member of 'tagDISPPARAMS'
|
|
|
|
|
Should be cArgs - mix up copying code from where I've used DISPPARAMS .
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Done!!!
I made slide changes 'cos of application was crashing due to invalid arguments.
VARIANTARG args[2];
V_VT(&args[0]) = VT_I4;
V_I4(&args[0]) = 12;
V_VT(&args[1]) = VT_I4;
V_I4(&args[1]) = 45;
param.cArgs = 2;
param.rgvarg = args;
param.cNamedArgs=0;
param.rgdispidNamedArgs=0;
thanx for replying.
|
|
|
|
|
IDispatch* DllBase::CreateClassComDispatch(BSTR sClassName)
{
CLSID clsid;
IUnknown *pUnk;
IDispatch *pDisp;
HRESULT hr;
CLSIDFromProgID(sClassName, &clsid);
hr = CoInitialize(NULL);
if(FAILED(hr))
return FALSE;
hr = CoCreateInstance(clsid,NULL,CLSCTX_ALL,IID_IUnknown,(void**)&pUnk);
if(FAILED(hr))
return FALSE;
hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
if(FAILED(hr))
{
pUnk->Release();
return FALSE;
}
return pDisp;
}
GetPrinterList(char* printLib, char* printersUrl, char* username, char* password)
{
char* retValue = NULL;
HRESULT hr;
DISPID idd;
VARIANTARG varResult;
IDispatch *pDisp;
try
{
VariantInit(&varResult);
retValue = NULL;
//lib
_bstr_t bstrLib = _bstr_t(printLib);
pDisp = CreateClassComDispatch(bstrLib.GetBSTR());
if(pDisp == NULL)
return NULL;
//function
LPOLESTR str = L"GetPrinterList";
//params
int ParamsNumber = 3;
VARIANTARG avarParams[3];
for(int i=0;i<paramsnumber;i++){>
::VariantInit( &avarParams[i] );
}
_bstr_t bstrTemp1 = _bstr_t(password);
avarParams[0].vt = VT_BSTR;
avarParams[0].bstrVal = bstrTemp1.copy();
_bstr_t bstrTemp2 = _bstr_t(username);
avarParams[1].vt = VT_BSTR;
avarParams[1].bstrVal = bstrTemp2.copy();
_bstr_t bstrTemp3 = _bstr_t(printersUrl);
avarParams[2].vt = VT_BSTR;
avarParams[2].bstrVal = bstrTemp3.copy();
DISPPARAMS params = { avarParams, NULL, ParamsNumber, 0 };
//get ID
hr = pDisp->GetIDsOfNames(IID_NULL,&str,1,NULL,&idd);
if(!FAILED(hr))
{
hr = pDisp->Invoke(idd, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
if(FAILED(hr))
retValue = NULL;
else
{
_bstr_t retvalue = _bstr_t(varResult.bstrVal);
retValue = strdup((char*)retvalue);
}
}
else
{
retValue = NULL;
}
for(int j=0;j<paramsnumber;j++){>
::VariantClear( &avarParams[j] );
}
::VariantClear( &varResult );
return retValue;
}
catch(...)
{
}
return NULL;
}
|
|
|
|
|
I'm working on an application where i have a requirement to delete the XML data which is between certain dates. However i was able to get the data within those particular dates given by the user but i have no idea how to delete them.
Please let me know if there is any function ???
I even used removechild function but the application is getting crashed.
|
|
|
|
|
will you show the code to delete required node?
|
|
|
|
|
brucewayn wrote: I'm working on an application where i have a requirement to delete the XML data which is between certain dates. However i was able to get the data within those particular dates given by the user but i have no idea how to delete them.
You mean a xml file, right ?
If that's the case you have to rewrite the full file without the data you want to delete. Now, how to do it really depends on what you are using to read the xml file. In general most of the libraries allow you to also write xml back to a file.
brucewayn wrote: I even used removechild function but the application is getting crashed
removechild ? Where's that coming from ? I guess it is coming from a specific library but it would help a lot if you provide information about what you are using.
|
|
|
|
|
I am giving you idea to delete data from xml, it will be useful to you
MSXML2::IXMLDOMNodeListPtr pNodeList1 = ePtrRootXML->selectNodes("//parentOfDatenode");
while(MSXML2::IXMLDOMNodePtr pTemp = pNodeList1->nextNode())
{
if(pTemp)
{
// if date is given by user no need
MSXML2::IXMLDOMNodePtr pFromDate = pTemp->selectSingleNode(".//fromdate");
MSXML2::IXMLDOMNodePtr pToDate = pTemp->selectSingleNode(".//todate");
strFromDate = (LPCTSTR)pFromDate->text;
strToDate =(LPCTSTR)pToDate->text;
OleDateTime olecurrentdate(COleDateTime::GetCurrentTime());
// convert strFromDate and strToDate to OleDateTime format n compare
if( olecurrentdate<=oleTodate) // delete if success
{
pSection->removeChild(pTemp);
DocptrXML->save(bstrOutputXML);//bstrOutputXML= XML name with full path
}
}
|
|
|
|
|
You said your application crashes, did you use your debugger to see where the problem occurs exactly ? Without using your debugger, you won't be able to go very far...
|
|
|
|
|
I suppose you replied to the wrong post (unsless Sam today is so crazy to call himsel Bruce ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Oh yes, I mixed the different posts... I guess it was too early in the morning
|
|
|
|
|
Hi All,
HWND FindWindow(LPCTSTR lpClassName,LPCTSTR lpWindowName);
In this function, how to find the lpClassName for particular dialog.
Regards,
Anitha
|
|
|
|
|
I have found WinSpy++ to be useful in finding class names for particular windows, or you could use CP's own WinSpy, part of a demonstration of code injection into another process. They're especially useful when you want to find the class name for Windows components (such as the task bar, for example).
Regards,
--Perspx
"A refund for defective software might be nice, except it would bankrupt the entire software industry in the first year." -Andrew Tanenbaum
"Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer." -Fred Brooks
|
|
|
|
|
GetClassName
«_Superman_»
|
|
|
|
|
IIRC, all dialogs are of class #32770 .
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi all,
I have made a application in vc2008, I have made a TCHAR variable...
TCHAR prdcode[10];
My problem is i want to assign this value to CString variable...
CString test = prdcode;
but while assigning value it takes some garbage value....
how can i do it...
thanks in advance
|
|
|
|
|
VCProgrammer wrote: but while assigning value it takes some garbage value....
How do you check that ?
In oyur code snippet, you didn't assign anything to prdcode, so it will contain garbage at that time. Show use the code where you write something in it.
|
|
|
|
|