|
hi. i am working on a project with a graphical interface. when i run my project after 1 or 2 minutes my projects became very Very Slow. is there any resources that i should had released them ?? i am using GDI+. i did my best but i didn't find any resources that can be released.
thanx AnyWay
void CCheckersView::OnPaint()<br />
{<br />
CPaintDC dc(this);
<br />
Graphics graphics(dc.m_hDC);<br />
<br />
ColorMatrix colorMatrix = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f,<br />
0.5f, 1.0f, 0.0f, 0.0f, 0.0f,<br />
0.0f, 0.0f, 1.0f, 0.0f, 0.0f,<br />
0.0f, 0.0f, 0.0f, 0.2f, 0.0f,<br />
0.0f, 0.0f, 0.0f, 0.0f, 1.0f};<br />
ImageAttributes imageAtt;<br />
imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault,ColorAdjustTypeBitmap); <br />
for (int n=1;n<=18;n++) {<br />
for (int i=1;i<=del.n;i++)<br />
graphics.DrawImage(Bitmap::FromResource( AfxGetInstanceHandle(), (LPCWSTR) AKEINTRESOURCE(IDB_BMP)),Rect(0,0,67,67),0,0,67,67,UnitPixel,&imageAtt); <br />
<br />
SolidBrush s(Color(255, 114, 70, 57));<br />
for (int j=0;j<=7;j++)<br />
for (int i=0;i<=3;i++)<br />
graphics.FillRectangle(&s,i*(l*2)+x+(((j+1)%2))*l,y+j*l,l,l);<br />
<br />
<br />
<br />
<br />
}
|
|
|
|
|
I guess the Bitmap * returned by Bitmap::FromResource should be delete d after use.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Does anybody know how to make a controlbar that resizes when the framewindow resizes?
I've tried a couple of different approaches: catch the WM_RESIZE msg, used the RecalcLayout and looked around for information ... but I can't get it to work!!! Can somebody please tell me how this is done.
What I want to do can't be that difficult. I want to build a Search_bar that acts like the Address controlbar in windows explorer where the combo-box rezises to fit the main-frame.
|
|
|
|
|
Okay> I finally figured out thanks to CP gurus, how to create a submenu appended to a top level menu dynamically. I know the titles of the submenu items. THey have no IDs (maybe I need them after all?)
I want to give each submenu item its own little flyout dropdown menu (doesnt need to do anything when clicked).
So how do you give a dynamic submenu item a flyout? Should this be done in the same breath as creating the dynamic submenuitem, while one still have all the handles etc? Or later afte rall the submenu items have been dynamically created?
SO far I find the toplevel menu items pos, and then do:
CMenu* submenu = mmenu->GetSubMenu(pos);
Then do an Appendmenu on the "submenu" pointer. For each submenu I want a subsubmenu.....
To use the appendmenu I had to create a physical dummy resource submenu, or else GetSUbMEnu retiurns a null pointer. But definitely at the point when I want the subsubmenu I cant create a dummy resource for each submenu item (since its not been created in the resource editor...)
Appreciate your help,
ns
|
|
|
|
|
While awaiting perhaps more sensible responses, I am going to implement the WM_MENUCOMMAND when the non-ID bearing submenu item is clicked.....
Except the snag is that my flyouts are contained as the values in the container:
std::map<cstring, std::set<cstring="">> myMAp, and the key of this map is the submenuitem and the values of each key are in the flyouts. It would be better if I went along iterating through the CString keys recognizing them on the submenu titles and triggering the WM_MENUCOMMAND instead of my index..
Appreciate your help,
ns
|
|
|
|
|
Its done the same way you added the "flyout" menu as a top level one. Create a new sub menu and append/insert that to the previous sub-menu that was added as a flyout.
I wrote a function to do this a while back that worked with Brent Corcums BCMenu class. I have a modified version of it here to work with CMenu. Its basically a hacked version of that to use CMenu. Its not been checked/tested, so some of the calls on CMenu may be wrong, but you should be able to find the correct version of the function in MSDN
bool AddMenuItem(CMenu *menu, CString& menu_name, CString& menu_option, int menu_index, bool first, int suggested_position)
{
int sub_menu = 0 ;
int num_items = 0 ;
CString pop_up_menu_name = "" ;
CString name ;
int pos = 0 ;
pos = menu_name.Find('\\') ;
if (pos < 0)
{
num_items = menu->GetMenuItemCount() ;
for (sub_menu = 0 ; sub_menu < num_items ; sub_menu++)
{
menu->GetMenuString(sub_menu, pop_up_menu_name, MF_BYPOSITION) ;
if (pop_up_menu_name == menu_name)
break ;
}
if (sub_menu == num_items)
{
CMenu *menuPopup ;
menuPopup = new CMenu ;
menuPopup->CreatePopupMenu() ;
menuPopup->AppendMenu(MF_STRING, menu_index, _T(menu_option)) ;
if (first)
menu->InsertMenu(num_items - 2, menu_name, MF_POPUP | MF_BYPOSITION, (UINT)menuPopup->m_hMenu, NULL, 0) ;
else
{
if (suggested_position < 0)
menu->InsertMenu(num_items, menu_name, MF_POPUP | MF_BYPOSITION, (UINT)menuPopup->m_hMenu, NULL, 0) ;
else
menu->InsertMenu(suggested_position, menu_name, MF_POPUP | MF_BYPOSITION, (UINT)menuPopup->m_hMenu, NULL, 0) ;
}
}
else
{
menu->GetSubMenu(sub_menu)->AppendMenu(menu_option, MF_OWNERDRAW, menu_index);
}
}
else
{
name = menu_name.Left(menu_name.Find('\\')) ;
menu_name = menu_name.Right(menu_name.GetLength() - name.GetLength() - 1) ;
num_items = menu->GetMenuItemCount() ;
for (sub_menu = 0 ; sub_menu < num_items ; sub_menu++)
{
menu->GetMenuString(sub_menu, pop_up_menu_name, MF_BYPOSITION) ;
if (pop_up_menu_name == name)
break ;
}
if (sub_menu == num_items)
{
CMenu *menuPopup ;
menuPopup = new CMenu ;
menuPopup->CreatePopupMenu() ;
AddMenuItem(menuPopup, menu_name, menu_option, menu_index, bitmap, false, suggested_position) ;
}
else
{
CMenu *menuPopup ;
menuPopup = menu->GetSubMenu(sub_menu) ;
AddMenuItem(menuPopup, menu_name, menu_option, menu_index, bitmap, false, suggested_position) ;
}
}
return true ;
}
If there is anything about MF_OWNERDRAWN, just remove it.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
Hi Roger,
I havent checked out your sample code yet.
The one snag I can see with repeating the flyout technique is that for the toplevel menu, to get the submenu pointer I had to have a dummy submenu item already created via the resource editor, else I got a null submenu pointer. I cant very well supply a resource editor drawn in flyout submenu dummy item for the flyout sussubmenus pointer.......................
Appreciate your help,
ns
|
|
|
|
|
Actually, the code I posted takes care of that condition. If you have a top level menu of:
"File Edit Window Help"
And need to add "Options\MyOptions", it will look for an exisiting "Options" menu. If it exists it will all the items, if not, it will be created and inserted into the top level menu.
THe only way I see it not working would possibily be if you subsequently removed all the sub-menu items and tried to append to an empty top level menu, but your delete menu item function should be written to take care of this situation.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
Using segmenyts of your code I got my flyouts to work. Many thanks.
Appreciate your help,
ns
|
|
|
|
|
The menu_index you have in your code: are you just creating something like menu_index = 5000, and doing a menu_index ++ on it to append subsequent sublevel 1 submenus? How d oes one know if 5000 is "safe" to use as an ID? Presumably to capture clicks on the menu itemn you identify it by the menu_index...?
Appreciate your help,
ns
|
|
|
|
|
7 years later...
Needed sub menus, found your post, helped, thanks!
|
|
|
|
|
Long time ago someone showed me how to set up the release version so it can be debugged just like the debug version. But I dont remember it...???
Appreciate your help,
ns
|
|
|
|
|
in project / settings / C/C++ / general, change "debug info" to C7 or program database.
in project / settings / C/C++ / general, set optimizations to "disable(debug)".
in project / settings / link, check the box that says "generate debug info"
-c
Zzzzz...
|
|
|
|
|
A million thanks!!!
Appreciate your help,
ns
|
|
|
|
|
my program prints out a form with lots of text on it, and the last thing it prints is a line of text in a different font.. on every machine but one this works fine. that machine prints to the printer with everything in the same font, but it displays it on the screen with the correct font. i can print to this printer from my machine and it prints fine.
here is my code, is there any chance this is my fault, and not a problem with the printer driver? thanks for any suggestions!
for (int i = 0; i < m_oaText->GetSize(); i++)
{
CTextPrintObject* pOrigObj = (CTextPrintObject*)m_oaText->GetAt(i);
CTextPrintObject* pObj = GetScaleTruncTextOffset(pOrigObj);
if (pObj->m_nPage == m_nPagePrinting - 1)
{
UINT uOldAlign = pDC->SetTextAlign((pObj->m_nAlignment == 1) ? TA_RIGHT : TA_LEFT | TA_TOP | TA_NOUPDATECP);
if (pObj->m_strIDENT == "C_SCANLINE")
{
if (!fnBig.CreatePointFont(pObj->m_nSize,"OCR-A",pDC))
AfxMessageBox("Unsucessful in creating the OCR-A font");
}
else
fnBig.CreatePointFont(pObj->m_nSize,"Courier New",pDC);
CFont* pOldFont = pDC->SelectObject(&fnBig);
double dPosX = (2 + pObj->m_nPosX) * 1.003;
int nPosX = CFPCF::_round(dPosX * 10);
int nPosY = CFPCF::_round(pObj->m_nPosY * 10);
int nOffsetX = CFPCF::_round((pApp->m_dPrintOffsetX + DEF_PRINT_OFFSET_X) * 1000);
int nOffsetY = CFPCF::_round((pApp->m_dPrintOffsetY + DEF_PRINT_OFFSET_Y) * -1000);
pDC->TextOut(nPosX + nOffsetX, nPosY + nOffsetY, pObj->m_strText);
pDC->SelectObject(pOldFont);
pDC->SetTextAlign(uOldAlign);
fnBig.DeleteObject();
}
delete pObj;
}
also, this same machine when printing screws up my rotated text which I'm doing elsewhere, it completely screws up the rotation and the sizing.
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
One possible reason is that the printer driver has been setup to let the printer generate the printed image. If this is the case, you can only get the fonts/output correctly if the printer can actually generate that output. Check the printer driver settings and see if it can be configured to get windows to generate the image and send that to the printer.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
From MSDN:
CMenu* mmenu = GetMenu();
int pos = FindMenuItem(mmenu, "&File");
if (pos == -1)
return;
Here I want to append a submenu under "File". THere are no existing submenu items...
<code> CMenu* submenu = mmenu->GetSubMenu(pos);
pos = FindMenuItem(submenu, "&New\tCtrl+N");
if (pos > -1)
submenu->RemoveMenu(pos, MF_BYPOSITION);</code>
THe code in red is not what I want to do . I want to add stuff under "File" presuming it starts with nothing under it. Or do I resort to the cheap trick of putting in a submenu item with Resource editor, and then doing a removemenu on it? ANd then appendmenu my stuff?
Basically code> CMenu* submenu = mmenu->GetSubMenu(pos); - will this give me a pointer even if I dont have a submenu at all yet?
Appreciate your help,
ns
|
|
|
|
|
Or do I resort to the cheap trick of putting in a submenu item with Resource editor, and then doing a removemenu on it?
Start with an empty submemu (this won't show up if there are no subitmes, so the trick is neat), and (programmatically) add items to it. No need to remove anyhing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hmmmm...crashed with an empty pointer "submenu" when I did: (all i have is a toplevel menu). Pos comes out correct
void CMainFrame::OnMakemenu()
{
CMenu* mmenu = GetMenu();
int pos = FindMenuItem(mmenu, "test dyn");
if (pos == -1)
return;
CMenu* submenu = mmenu->GetSubMenu(pos);
submenu->AppendMenu(MF_STRING, 0, "Dog");
}
int CMainFrame::FindMenuItem(CMenu *Menu, LPCTSTR MenuString)
{
ASSERT(Menu);
ASSERT(::IsMenu(Menu->GetSafeHmenu()));
int count = Menu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
CString str;
if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
(strcmp(str, MenuString) == 0))
return i;
}
return -1;
}
Appreciate your help,
ns
|
|
|
|
|
You're right, I've just tested and my assumption doesn't work.
Well the solution then will require some extra work: after locating the
File item, if the popupmenu is empty then you'll need to create a new popup menu
(remember to hold it as a member of your window) and append at its right location like this:
submenu.CreatePopupMenu();
submenu.AppendMenu(MF_STRING, ID_APP_EXIT, (LPCTSTR)"E&xit");
mmenu->ModifyMenu(pos,MF_BYPOSITION|MF_POPUP,(int)(submenu.m_hMenu),"&File");
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hey Joaquin! Thank you so much for all the hard work on my behalf! I like your solution better...I was adding a fake item from the resource editor and doing a remove or deletemenu on it...
I guess your method is a little different from what I found: (no CreatePopupMenu)
void CMainFrame::OnMakemenu()
{
CMenu* mmenu = GetMenu();
int pos = FindMenuItem(mmenu, "test dyn");
if (pos == -1)
return;
CMenu* submenu = mmenu->GetSubMenu(pos);
pos = FindMenuItem(submenu, "junk");
if (pos > -1)
submenu->RemoveMenu(pos, MF_BYPOSITION);
submenu->AppendMenu(MF_STRING, 0, "Dog");
}
int CMainFrame::FindMenuItem(CMenu *Menu, LPCTSTR MenuString)
{
ASSERT(Menu);
ASSERT(::IsMenu(Menu->GetSafeHmenu()));
int count = Menu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
CString str;
if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
(strcmp(str, MenuString) == 0))
return i;
}
return -1;
}
MAny many thanks!!!!
Appreciate your help,
ns
|
|
|
|
|
You are welcome
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Gosh!!!! Today I realized the power of your resolution in this post> Yesterday I wasnt understanding it! It has enabled me to create my popup menu flyout!!!!!
I cant thank you enough. I am so glad I saw the meaning of your resolution this morning since it didnt sink in yesterday.
Appreciate your help,
ns
|
|
|
|
|
hello,
i'm having a little trouble reading data from a cdrom. i have an application
which records cds with the help of a 3rd party product. i insert a blank
cd, record and want to verify the data afterwards with the directory, and
do not want to read the iso from disc again. but the windows directory is
not refreshed after recording. i do not want to enable autoinsertnotification
because of possible recording errors. and i do not want to eject and load the
disc after recording. another problem is that the system remembers the directory
even if i eject the disc and put in another blank one. then i read the directory
and files and it works in the beginning until a read error occurres.
is there any possibility to trigger a "manual" insert notification, or to
clear the cd cache? or am i doing anything wrong?
thanks,
enrico
|
|
|
|
|
some burners (including mine) will never recognize a burned disk until the drive is ejected and closed, it wont beleive there is anything on the disk until then.. my nero burning program opens and closes my drive before doing any verification..
hope that helps.. if not, good luck!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|