|
Comparing Debug and Release Mode
Debug mode compiles and links the code such that it can be run with the debugger. This lets you single step through the source code, set breakpoints, and examine variables during execution. Release mode code cannot be run under the debugger with full source code information available.
Compiling for debug turns off all optimizations in order to make debugging easier. This makes the code slower and much larger than release mode. When you compile in release mode, you can choose the optimizations that the compiler performs. Optimizations can generate faster code, or make the resulting .EXE smaller, or any of a wide variety of choices for performance tuning.
Debug code cannot be distributed, because it runs with the debug libraries for the 'C' runtime, MFC, etc. The debug libraries may not be distributed, since they are licensed as part of the development package. Release mode code runs with the release libraries, which you are allowed to distribute.
The debug versions of the runtime libraries behave differently from the release versions. The heap functions (new , delete , malloc , free , and so on) change how they allocate memory so that they can detect when you have overrun allocated buffers or make other allocation errors. Functions in the libraries tend to check their arguments and ASSERT when you've supplied an invalid value. These error checks are not used in the release libraries, which means these errors can go undetected until the program crashes.
Which Should I Use?
Typical practice is to start out developing and testing your program in debug mode. When you think you've got the program working correctly, and you have tested it thoroughly, compile it for release and test it again. When your program is compiled for release, it may behave somewhat differently from the debug version. It will probably run faster. It will probably use less memory than the debug version. If the program is multithreaded, you may see threading problems that you did not see in the debug version, due to the timing changes.
Software Zen: delete this;
|
|
|
|
|
how to get #322776(Dialog) class 's handle
d
|
|
|
|
|
How to get #322770(Dialog) class 's handle
d
|
|
|
|
|
I think you mean #32770 .
You can use FindWindow() to find the window handle of a window with the dialog class, but you will need more information to find the window you are after as there is typically many dialogs open at the same time.
HWND hWnd = FindWindow(_T("#32770"), _T("Dialog Caption"));
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
That depends on if it's your own dialog, or someon eelses. Most likely, it's from another app, right? Then you might want to check FindWindow and - as you might not have the caption - EnumWindows and EnumChildWindows .
|
|
|
|
|
Dear viewers,
I want to create a window in mfc that will contain no menubar,titlebar etc. just a window with borders so that
it can be used to show images or something appropriate
in this case. so is there any way out? plz help me.
|
|
|
|
|
Leave off the WS_CAPTION style when you create the window.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
here a small code you put in CFrameWnd derived class Constructor
Create(0//class name,"helloo alok"//Windows caption,don't woory it not going to show up,WS_BORDER|WS_VISIBLE);
this code will solve your problem
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I decided to hack up my own tab control functionality. Instead of having a "simple" tab control, I thought I'd make a tab control a'la .NET/Winforms. By that I mean I have a method called AddSheet(title, hWndSheet) . The tab control will then itself keep track of what sheet to show, etc. I believe there is such functionality in MFC already, but since I'm not using MFC, that's not an option.
So, onto the specifics of the problem.
When all the tabs can be displayed inside the client area, all is fine and dandy. But as soon as the area becomes too small, and it displays the scroll buttons in the top right corner, my children are clipped. The weirdest part is that only buttons are affected by the clipping. I've put list controls in there, as well as my own controls. If I turn off theming (Windows Classic Style), no clipping is done.
As I don't have a good way to put up a screenshot, I'll do my best to describe the clipping by using words and ASCII art.
Here's the tab control:
+---------------------------------------+
| Tab 1 | Tab 2 | Tab 3 | Tab 4 | < | > | <- Here's the two scroll buttons
+-------+-------------------------------+
|+-------------------------------xxxxxxx|
|| xxxxxxx|
|| A Button xxxxxxx| <- x marks the clipped area
|| xxxxxxx|
|+-------------------------------xxxxxxx|
+---------------------------------------+
The clipped area is everything to the right of the scroll buttons left edge. The clipped area is drawn with the tab control background, and not some grey left over color from background erasing.
I have fiddled with sibling & children clip styles on the tab control, but none of that has helped.
Possibly worth knowing is that I have subclassed the tab control. I override WM_SIZE where I resize the child controls (using AdjustArect and all - it does work which one can see easily when the darn thing isn't clipping my buttons). I have not overridden any painting message, so I don't think I'm doing the clipping explicitly.
Any clues? I am perplexed.
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Jörgen Sigvardsson wrote:
The tab control will then itself keep track of what sheet to show, etc. I believe there is such functionality in MFC already, but since I'm not using MFC, that's not an option.
I believe you are talking about MFC's CPropertySheet and CPropertyPage classes. These classes are a wrapper around the WIN32 propertysheet functions.
Check MSDN for:
PropertySheet()
PROPSHEETHEADER
PROPSHEETPAGE
PSM_* messages
PropSheet_* macros (PSM_* wrapper macros)
PropSheetProc()
PropSheetPageProc()
etc.
While MFC is definitely easier to use, using these ready made WIN32 functions has got to be easier than rolling your own. But then again, maybe you are a glutton for punishment.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote:
While MFC is definitely easier to use, using these ready made WIN32 functions has got to be easier than rolling your own. But then again, maybe you are a glutton for punishment.
As I'm currently reinstalling everything at home (including Windows), I don't have MSDN yet. However, aren't these functions for property page dialogs and the likes? The tab controls are just building blocks in a bigger picture for me, and I'd like to stay away from dialog resources, for technical and aestethical reasons.
Anyway, I think I understand why the buttons behave like they do on tab controls. Buttons use their parents DC to render themselves. I suspect the tab control does some weird clipping when it's themed, resulting in the clipped button. I believe I have one of three options:
1) Hack my way through tab control & buttons and back again: Mission Impossible
2) Write my own button class (silly, but quite doable)
3) Create a host window which all child controls lie on.
I think 3) is the smartest choice. It will assure that my DC isn't screwed with, and I believe this is how it's generally done. However, I think I will make the host window transparent, so that the tab control background shines through. Doesn't do much on a Win2k machine, but on an XP machine, the gradient will look pretty nice.
I will however have a look at the functions you mentioned, as soon as I've got everything installed again (tomorrow if I'm lucky ) Thanks for the tip, much appreciated!
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Jörgen Sigvardsson wrote:
aren't these functions for property page dialogs and the likes?
Yes they are.
But you could still use them, you would just have to create an empty (as in no controls) DLGTEMPLATE structure in memory, and use that to create the pages. Then dynamically create all your controls on the page later. I am sure there are many was to skin that cat and you will find the best one for you.
Have fun!
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
can we have a screenshot?
I have an ActiveX that basically does the same, but doesn`t exhibit the problem
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
I can't give you a screenshot I'm afraid. 1) I'm not at the office, 2) I don't have a good server to put it on.
Besides, I think I know a workaround. It's the damn button's fault; it uses its parent's DC, which is clipped somehow by the scrollbuttons in the tab control. If I put a window which uses its own DC on the tab control, which hosts the child controls, it should work. And that is probably the "trick" too. Almost all tab controls I've seen, has all of its children on a dialog child control. A dialog child control has its own DC, and is thus not affected by peculiarities of the tab control.
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
I've managed to add a button to the IE main toolbar using the extension configuration section in the registry and I've implemented an IOleCommandTarget COM object to handle the button click.
The question is, how can I get the co-ordinates of my button out of IE so that I can display my menu of options neatly aligned below it? Any help or pointers to info would be gratefully appreciated!
|
|
|
|
|
Hi,
I am using the string table to hold all the UI string I use in my application. However I cannot seem load them into my program. this is the sequence i use:
CString test;
int y;
DWORD Failure;
y = test.LoadString(IDS_APN);
Whenever i call the GetLastError() commnad, the error code indicates the string is not present, even though it is present in both the string table editor and the Resource.h file.
What am i doing wrong?
Thanks in advance,
femi.
|
|
|
|
|
You have shown almost no code, and some of it even unrelated (the DWORD-declaration), so the answer you'll get will most likely be "no idea". And in fact it is. The problem could be that you try to do this from a DLL, that the string id in the string table is actually "IDS_APN", not IDS_APN (a significant difference), that you have spelled the resource id wrong, but still the same as another resource id in resource.h, etc. etc. etc.
|
|
|
|
|
Your right there is almost no code, thats because i didnt get past that line, the DWORD was used to retreive the error code after the 'LoadString' command. But i am loading the string from a dll, from your reply i take it that isnt normally possible?
|
|
|
|
|
It is possible to load a string in a DLL, but there are some things that will have to be considered first. A short background:
Resources are loaded from an application/DLL using the app/DLL HINSTANCE (that is a unique identifier for this instance of the app/DLL - a little bit like a window handle for the whole module, if I'm allowed to stretch my analogies). MFC hides this, in the API-wrappers normally taking the HINSTANCE as an in-parameter (such as ::LoadString ), a hidden HINSTANCE for the application is used. A DLL gets to be a part of the application, so if you access resources from the DLL, they are loaded from the application instead of the DLL. Fiasco!
It is possible to switch the context over to the DLL for the call, you will want to search for and read about - firstly - AfxSetResourceHandle and secondly AFX_MANAGE_STATE in MSDN.
|
|
|
|
|
Hi! I want to custom-draw menubar in MFC MDI. Is there anyway to get menubar m_hWnd so that we can hook WNDPROC. Thanks
|
|
|
|
|
The menu bar isn't traditionally a window. Don't try looking up Explorer or Internet Explorer using Spy++, though, as that will indicate a window handle... of a toolbar. Ditto Visual Studio and Office.
You can owner-draw menu items by adding the MFT_OWNERDRAW flag to the menu item using SetMenuItemInfo . Windows then sends the window WM_MEASUREITEM and WM_DRAWITEM messages.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
i am facing a weird problem
i am using XP icons imporitng them adding them to the imagelist attaching it with the ctreeview
m_ImageList.Create(16,16,ILC_COLOR32|ILC_MASK,4,4);
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
GetTreeCtrl().SetImageList(&m_ImageList,TVSIL_NORMAL);
But the Icons don't show right (seems they are painted with less colors)
but he same code and same icons are wokring with CListCtrl just fine
any ideas , can CImagelist handle such icons it must cause CListCtrl is painting them just right
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
http://www.mastishk.com
|
|
|
|
|
Here is a snippet of code I wrote last month. It makes a CTreeview with a list of icons (big size) on the left with a description on the right side (2nd column). Dont forget, icons have 2 sizes, small and big. See if you can understand what I wrote:
CImageList * m_pImageList;
CImageList * m_pImageListSmall;
<view file="">
// insert two columns (REPORT mode) and modify the new header items
m_ctlDatabaseList.GetWindowRect(&rect);
m_ctlDatabaseList.InsertColumn(0, strItem1, LVCFMT_LEFT, rect.Width() * 3/9, 0);
//spaces them equally. This is a header of the CTree control
m_ctlDatabaseList.InsertColumn(1, strItem2, LVCFMT_LEFT, rect.Width() * 1/3, 1);
m_ctlDatabaseList.InsertColumn(2, strItem3, LVCFMT_LEFT, rect.Width() * 2/7, 2);
///create the icons
CRect rect;
CzScanApp *pApp;
pApp = (CzScanApp*)AfxGetApp();
m_pImageList = new CImageList();
m_pImageListSmall = new CImageList();
ASSERT(m_pImageList != NULL && m_pImageListSmall != NULL);// serious allocation failure checking
m_pImageList->Create(32, 32, TRUE, 4, 4); //This is a large icon
m_pImageListSmall->Create(16, 16, TRUE,4, 4);//this is the small icon from the same file
m_pImageList->Add(pApp->LoadIcon(IDI_ICON1));
//Icons have 2 sides to them, small size and large size
//.....ADD AS MANY ICONS YOU WANT SO LONG AS YOU HAVE THE ICON FILES STORED TO USE
m_pImageList->Add(pApp->LoadIcon(IDI_ICON50));
//Icons have 2 sides to them, small size and large size
///now add the icons to show
for (iItem = 0; iItem < Limit; iItem++) // insert the items and subitems into the list view.
{
if(GROUP[iItem+1][0].NoOfDACs== 0)
continue;
for (iSubItem = 0; iSubItem < 3; iSubItem++)
{
if (iSubItem == 0)
iIcon = ++a; // choose the icon and legend for the entry
lvitem.mask = LVIF_TEXT | (iSubItem == 0? LVIF_IMAGE : 0);
lvitem.iItem = (iSubItem == 0)? iItem : iActualItem;
lvitem.iSubItem = iSubItem;
// calculate the main and sub-item strings for the current item
pStrTemp1= strIconShortDesc[iIcon].GetBuffer(strIconShortDesc[iIcon].GetLength());
pStrTemp2= strIconDesc[iIcon].GetBuffer(strIconDesc[iIcon].GetLength());
pStrTemp3= strIcon3rdCol[iIcon].GetBuffer(strIcon3rdCol[iIcon].GetLength());
//lvitem.pszText = iSubItem == 0? pStrTemp1 : pStrTemp2;//2;
switch(iSubItem)
{
case 0:
lvitem.pszText = pStrTemp1;
break;
case 1:
lvitem.pszText = pStrTemp2;
break;
case 2:
lvitem.pszText = pStrTemp3;
break;
default:
break;
}
lvitem.iImage = iIcon;
if (iSubItem == 0)
iActualItem = m_ctlDatabaseList.InsertItem(&lvitem);
// HERE, IT INSERTS A NEW ICON WITH A DESCRIPTION
else
m_ctlDatabaseList.SetItem(&lvitem);
// HERE, IT MODIFIES AN EXISTING ICON WITH DESCRIPTION, (the sub-item text)
}//for(iSubItem
|
|
|
|
|
when test my program using rational purify it shows
memory leak.
the memory leak is shown in recv()
/* message, as shown by rational purify */
[W] MLK: Memory leak of 48 bytes from 1 block allocated in recv [WSOCK32.dll]
Distribution of leaked blocks
48 bytes from 1 block of 48 bytes (0x001bad90)
Allocation location
RtlAllocateHeap [NTDLL.DLL]
recv [WSOCK32.dll]
mainThread(void) [mainthread.h:70]
wndProc(HWND__ *,UINT,UINT,long) [wndproc.h:199]
PeekMessageA [USER32.dll]
msgLoop(void) [esme.cpp:61]
WinMain [esme.cpp:107]
WinMainCRTStartup [crt0.c:198]
/* in program */
BYTE bt[750];
int rcvd=0;
rcvd = recv(sckID,(char *)bt,500,0);
|
|
|
|
|
Did you call shutdown to close the connection (TCP only), closesocket to close the socket, and WSACleanup to clean up the Windows Sockets stack?
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|