|
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 /.
|
|
|
|
|
thx. Am I bound to use MFC... or can I also make my own classes (it's a network class here) a DLL?
|
|
|
|
|
Chris Losinger wrote:
you can only export a class from a DLL if you make an MFC (or "extension") DLL.
That is not true. Create a new Win32 DLL project in VC++ and select the option to export some symbols, a plain C++ class will be exported.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
???
i've been wrong on this point for years.
is it that you can only export MFC object from an MFC DLL?
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
Chris Losinger wrote:
is it that you can only export MFC object from an MFC DLL?
Think that is correct, because you need to have the CWinApp object to work with. However, a MFC extension DLL is a special type of DLL that uses the MFC applications CWinApp object instead of creating its own.
Then there is a regular DLL that can export functions and C++ objects.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|