|
In script engine, I can use IActiveScript->AddNamedItem() to add a root level item. But how to add a 2nd level named item ?
I can add the root level "Application", but I don't know how to add a second level "Documents" to "Application".
Does anyone know ?
Is it only first level item can have event ?
Thanks
|
|
|
|
|
The second level is accessible via the first levels IDispatch interface - i.e. if you have a Documents property, you could use Application.Documents in script. The script engine uses your IActiveScriptSite interface to get Application , then calls into Application to get Documents .
As for events...I believe the following should work (I'm assuming VBScript and an event called DoSomething )
Dim event_raiser
Sub event_raiser_DoSomething
some code
End Sub
Set event_raiser = Application.Documents
some more code, which causes DoSomething to be raised
I think you can handle events from any object you can reference like that. I'm not sure how you hook up events in JScript, but I guess the same is true.
<after looking @ MSDN>
It appears you can use a function of the form object_variable_name::event_name (which is like the VB example above) or something like object.event = function pointer , which I've never used, but sounds like it doesn't use
IConnectionPoint et. al. I'm not sure - does anyone know for sure?<br />
<code></after looking @ MSDN>
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
I am successfully conecting to *.mdb database on my local machine using following connection string:
HRESULT hr = m_pConnection->Open(
_bstr_t(L"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\source\\VCDb.mdb;"),
_bstr_t(L""),
_bstr_t(L""),
NULL);
Now i want to connect to SQL-Server running on the machine in my neighbourhood. The ip of target machine is 192.168.10.10. Plz tell me the connection string.
|
|
|
|
|
|
I don't know whether this is a correct forum to ask this question..Anyways.
I place certain font file in the windows fonts directory. It gets automatically register in the registry. At that time my application and other applications properly loads the font. But sometimes font automatically disappeaared both from fonts directory and registry especially when i restart my computer. Sometime when i refresh the fonts folder, the font appears again and related applications starts loading it normally. Can anyone tell me whats the problem
|
|
|
|
|
I have a char* buffer pBuf filled with a bitmap. I want to get the size of the bmp from this buffer so I see that I need stuff like:
BITMAPINFOHEADER &bmiHeader = *(LPBITMAPINFOHEADER)(what goes here?);
BITMAPINFO &bmInfo = *(LPBITMAPINFO)(what goes here?);
Thanks,
ns
|
|
|
|
|
pBuf
WWJD? JWRTFM. found on /.
|
|
|
|
|
hello all (incl chris L )
i have a popup menu in my sdi app...and this popup gets generated dynamically...full of all sorts of goodies and can get quite big
my quesiton is this:
where do i catch all messages from this menu ? so i can then figure out which one it was
- i can't prefine all the windows commands before the menu as the menu is built from a search on a database
cheers and thanks
Bryce
|
|
|
|
|
(hey )
when you build the menu, i assume you're adding menu items with InsertMenu ? if you are, then you are probably providing a "command ID" as one of the parameters. that ID is what you need to handle (and you should be using IDs you created with the Resource Symbols menu).
so, in whatever window you want to handle the message, add a line like this to the .cpp's MESSAGE_MAP
ON_COMMAND(ID_MY_MENU_ID, MyHandler)
add a line like this to the .h:
afx_msg void MyHandler();
then write the "void CMyVest::MyHandler()" function
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
yep thats cool and i knew dat
but i'd need one for each menu item
and theres no way of knowing at compile time how many there will be
i starts at abase of ID_BASE_SHORT_REF_COMMAND and increment for each item
do u see what i mean?
bryce
|
|
|
|
|
ah, yeah that's a problem. you could always just allocate yourself a range of resource IDs in your resource.h file (like 2x as many as you think you'll ever need).
i am working on app right now that essentially does this. i reserved 100 items in resource.h (copy paste, edit, boring). at run time, i keep a std::map around that maps the arbitrary menu ID to a meaningful identifier which i set when i add the menu items. i only have one menu handler, and it just takes the last message ID, looks it up in the map and then proceeds accordingly, when the user chooses one.
WWJD? JWRTFM. found on /.
|
|
|
|
|
what about catching it in a pretranslatemsg function or something and seeing if its mroe than ID_BASE_SHORT_REF_COMMAND and less than ID_BASE_SHORT_REF_COMMAND+menuitems
?
Bryce
|
|
|
|
|
yeah, i think that might work too. never know till you try
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
erm why not do this
ofstream out;
out.open("i:\\test.txt");
for (int index =1; index <= 1000; index++)
{
CString temp ;
temp.Format("#define ID_SHORT_REF_MENU%d %d",index,34000+index);
out <
|
|
|
|
|
yeah. i probably would've done the same, if i had a 1000 to do.
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
shoudnt u be in bed? its bloody late in yankeeland isnt it?
bryce
|
|
|
|
|
3:30 am.
zzz
i have a cool idea. i can't sleep!
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
coor when i have one i get told to write it down and get back to bed
|
|
|
|
|
Why not define ahead of time a range of ID's that are to be used for this dynamic menu generation and then use the message handler ON_COMMAND_RANGE( id1, id2, memberFxn )
You can define a range such as 100 - 200, which can correspond with the items in the database. When adding the menu items use this range value + WM_USER as below:
#define LOWER_RANGE WM_USER + ID_BASE_SHORT_REF_COMMAND
#define UPPER_RANGE WM_USER + ID_BASE_SHORT_REF_COMMAND + 100 // Replace 100 with a valid range value
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_COMMAND_RANGE(LOWER_RANGE, UPPER_RANGE, OnCustomCommand)
END_MESSAGE_MAP()
void CMainFrame::OnCustomCommand(UINT nID)
{
switch(nID)
{
case LOWER_RANGE:
// ... do something
break;
case LOWER_RANGE + 1:
// ... do something
break;
} // End Switch()
}
Not sure how you will relate what exactly these ID's correspond to in the database. You will have to figure this out.
|
|
|
|
|
Bill S wrote:
Why not define ahead of time a range of ID's that are to be used for this dynamic menu generation and then use the message handler ON_COMMAND_RANGE( id1, id2, memberFxn )
because if i want say 200, then i hafta go into the resrouce.h and #define 200(or whatever)
by hand...is there an easier way?
Bryce
|
|
|
|
|
bryce wrote:
because if i want say 200, then i hafta go into the resrouce.h and #define 200(or whatever)
Why do you have to define these in resource.h?
You can simply add another include file to the project that contains special defines, constants, etc. like "MyToolDefs.h" and add them there. Just add this new Project include file to the file list for the cpp file that needs it. In reality you don't even have to use defines or constants unless you want to make it easier to change the values in only a single place down the road.
Best Regards,
|
|
|
|
|
I want to programatically generate GUID and want to store it as a key in std::map. Plz tell me the way to programatically generate GUID and storing it in appropriate datatype/s
|
|
|
|
|
// Generate a unique GUID
GUID Guid;
HRESULT hr = ::CoCreateGuid(&Guid);
ATLASSERT(SUCCEEDED(hr));
specify the type of element in the container as GUID.
Best Regards
|
|
|
|
|
Hi there,
I created DLLs in the past from my C-code, now I want to do that also with C++ code?
Is this possible and do I feel much difference? Thanks for help and... perhaps with a link pointing me into the right direction (tutorial). Thanks!
|
|
|
|
|
you can only export a class from a DLL if you make an MFC (or "extension") DLL. and, then you can only use the DLL version of MFC in the project.
-c
WWJD? JWRTFM. found on /.
|
|
|
|