|
Nyarlatotep wrote: The question is why GetTextMetrics hangs. Never happened before !!!
This may due to following.
-You have taken the device context of the printer where lots of jobs may pending
-When you get the device context of printer and textout the text the device context is in use while jobs may pending or your process is not scheduled.
-and you are trying to get/set the information of the device context which may denied as exclusive access to device context
Hope you got the issue.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
please try the following code:
---------------------------------------
hOldFont = SelectObject(hfont1);<br />
GetTextMetrics(hdc,tm1);<br />
TextOut(hdc, ....);<br />
y += tm1.tmHeight + tm1.tmExternalLeading;<br />
<br />
SelectObject(hdc, hOldFont);<br />
DeleteObject(hfont1);<br />
<br />
hOldFont = SelectObject(hfont2);<br />
GetTextMetrics(hdc,tm2);
---------------------------------------
|
|
|
|
|
Selecting the old font and destroyng hfont1 works.
But in this way i've to re-create hfont1 each time (i use it in many places along with hfont2).
|
|
|
|
|
Hello,All
I have a application by Win32.I want to package it.
Please help me .
Thanks ...
|
|
|
|
|
Use NSIS installer for packaging it..you just have to write a simple script for that.
You can download the nsis installer from here[^]
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Package as in make an installer? The good free ones should be Inno Setup and NSIS.
|
|
|
|
|
Tran Ngoc Minh wrote: I have a application by Win32.I want to package it.
Please help me .
Use setup and deployment projects wizard of the VS2003
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hope I understood your question
one way that you dont need to any software you can use from IExpress.exe in XP from start menu and in window Run enter IExpress.exe now you can see a window Welcome
whitesky
|
|
|
|
|
Hi all,
My question is here :
To create a console application with the Class Hierarchy for the below XML Structure.
<Employees>
<Employee>
<name>Malar</name>
<designation>SE</designation>
<reportingTo>
<Employee>
<name>Prakash</name>
<designation>PL</designation>
</Employee>
</reportingTo>
</Employee>
</Employees>
//******************
I have to write a C++ program to add, modify, delete type application.
This application should append, delete, or modify the XML file.
I think each tag should be represented as seperate class since we have append the XML as tags
Advance thanks for the one who will help to solve the problem,
Regards,
Karthik M
Karthik M
|
|
|
|
|
karthikoncodeproject wrote: I think each tag should be represented as seperate class since we have append the XML as tags
This is not a good idea: imagine, you want to add a new tag. Then you have to create another class... Not very practical.
Take a look at tinyXML[^], it's a quite powerfull library.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
See IXMLDOM* interfaces which provides what you want.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Thanks for your valid suggestions.
But i have to write a C++ code manually for an assignment.
Kindly design a class for the above mentioned XML hierarchy.
Regards,
Karthik M
Karthik M
|
|
|
|
|
Hi,
Can someone explain why this code crashes (when calling ReleaseBuffer()) ?
<br />
#define PROFILE CString("config.ini");<br />
CString result;<br />
GetPrivateProfileString("MySection","MyString","",result.GetBuffer(),512,PROFILE);<br />
result.ReleaseBuffer();<br />
And how can I avoid this ?
|
|
|
|
|
I think you should specify the size of the allocated buffer:
GetPrivateProfileString("MySection", "MyString", "", result.GetBuffer(512), 512, PROFILE);
|
|
|
|
|
Hi
Please remove ';' in define line
KK
|
|
|
|
|
My guess is the crash is due to writing past the allocated buffer memory that the CString has. Debug builds have some checks to see if you make this mistake. Get the CString to return a buffer that has a certain minimum size.
<br />
#define PROFILE CString("config.ini");<br />
CString result;<br />
GetPrivateProfileString("MySection","MyString","",result.GetBuffer(512),512,PROFILE);<br />
result.ReleaseBuffer();<br />
|
|
|
|
|
Tnarol wrote:
GetPrivateProfileString("MySection","MyString","",result.GetBuffer(),512,PROFILE);
Result of the string where you get the data from ini file, it should be LPTSTR buffer, specify the size of that buffer instead of 512.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Try this:
#define PROFILE "config.ini";
CString result(_T(" "),512);
GetPrivateProfileString("MySection","MyString","",result.GetBuffer(),512,PROFILE);
result.ReleaseBuffer();
May be you are trying to release some memory not allocated.
|
|
|
|
|
For GetBuffer method :
Call this method to return the buffer contents of the CSimpleStringT object.
You are having this string empty.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
You have two compiler errors. The first is a missing argument to GetBuffer() . The second is an erroneous semicolon at the end of PROFILE .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi guys,
I was having a bit of trouble with certain tabs not displaying their appropriate dialog controls.
The options Dialog appears and shows it has 2 tabs. However when the 2nd tab is clicked, it becomes "on top" or becomes focused, but the dialog control associated with it does not appear below the tab. Basically if I click any tab, it shows only the dialog control associated with the general tab (1st tab) and not the dialog controls associated with the tab that was chosen by the user. Below is the code for your perusal:
<br />
BOOL CALLBACK OptionsDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
HWND tab1_hwnd = NULL;<br />
HWND tab2_hwnd = NULL;<br />
HWND CurrentTabHwnd = NULL;<br />
int CurrentTabIndex;<br />
HWND hwndTab = NULL;<br />
<br />
switch(msg)<br />
{<br />
case WM_INITDIALOG:<br />
{<br />
<br />
LPSTR tab1_title = "General";<br />
LPSTR tab2_title = "Advanced";<br />
<br />
INITCOMMONCONTROLSEX tabctl;<br />
<br />
tabctl.dwSize = sizeof(tabctl);<br />
tabctl.dwICC = ICC_TAB_CLASSES;<br />
<br />
InitCommonControlsEx(&tabctl);<br />
<br />
hwndTab = GetDlgItem(hwnd,IDC_TAB1);<br />
<br />
TCITEM ItemStruct;<br />
<br />
ItemStruct.mask = TCIF_TEXT;<br />
ItemStruct.pszText = tab1_title;<br />
ItemStruct.cchTextMax = sizeof(tab1_title);<br />
ItemStruct.iImage = 0;<br />
ItemStruct.lParam = 0;<br />
<br />
SendMessage(hwndTab, TCM_INSERTITEM, 0, (LPARAM)&ItemStruct);<br />
<br />
ItemStruct.pszText = tab2_title;<br />
ItemStruct.cchTextMax = sizeof(tab2_title);<br />
<br />
SendMessage(hwndTab, TCM_INSERTITEM, 1, (LPARAM)&ItemStruct);<br />
<br />
tab1_hwnd = CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_OPTIONS_GENERAL), hwndTab, General_OptionsDialogProc, 0);<br />
tab2_hwnd = CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_OPTIONS_ADVANCED), hwndTab, Advanced_OptionsDialogProc, 0);<br />
<br />
CurrentTabIndex = 0;<br />
CurrentTabHwnd = tab1_hwnd;<br />
<br />
ShowWindow(tab1_hwnd,SW_SHOWDEFAULT);<br />
<br />
<br />
}<br />
break;<br />
<br />
case WM_NOTIFY:<br />
{<br />
<br />
LPNMHDR lpnmhdr = (LPNMHDR) lParam;<br />
<br />
switch(lpnmhdr->code){<br />
case TCN_SELCHANGING:<br />
{<br />
ShowWindow(CurrentTabHwnd, SW_HIDE);<br />
SendMessage(hwndTab, TCM_GETCURSEL, 0, 0);<br />
<br />
switch(TabCtrl_GetCurSel(hwndTab)){<br />
case 0:<br />
ShowWindow(tab1_hwnd,SW_SHOWDEFAULT);<br />
CurrentTabHwnd = tab1_hwnd;<br />
CurrentTabIndex = 0;<br />
break;<br />
case 1:<br />
ShowWindow(tab2_hwnd,SW_SHOWDEFAULT);<br />
CurrentTabHwnd = tab1_hwnd;<br />
CurrentTabIndex = 1;<br />
break;<br />
}<br />
}<br />
break;<br />
default:<br />
return FALSE;<br />
}<br />
<br />
}<br />
break;<br />
case WM_COMMAND:<br />
{<br />
<br />
switch(LOWORD(wParam)){<br />
<br />
case IDOK:<br />
EndDialog(hwnd,0);<br />
break;<br />
case IDCANCEL:<br />
EndDialog(hwnd,0);<br />
break;<br />
}<br />
<br />
}<br />
break;<br />
case WM_CLOSE:<br />
EndDialog(hwnd, 0);<br />
break;<br />
<br />
default:<br />
return FALSE;<br />
}<br />
return 0;<br />
}<br />
<br />
Everything works correctly up until WM_NOTIFY case and even more specifically the "case TCN_SELCHANGING" code block and even more so there are issues associated with the Message TCN_SELCHANGING.
I want to know how do I find out through the message system which tab index is selected? If I can find out which tab index is selected then I can easily write code that will show the appropriate dialog window under the selected tab.
Thanks for your help,
Robbie
|
|
|
|
|
wrote:
HWND tab1_hwnd = NULL;
HWND tab2_hwnd = NULL;
HWND CurrentTabHwnd = NULL;
int CurrentTabIndex;
HWND hwndTab = NULL;
The HWND variables are destroyed when you return from the callback procedure..
Due to which when next time the procedure called it declares the HWND variables and WM_INITDIALOG message fire only once..
solution for this is make the variables as static/global.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hey guys,
Thanks a lot for your help, it actually works now. Declaring the handles as static actually fixed the darn thing. I never realized the callback procedure kills the handles everytime its returned but I can see why that problem was occuring. Im just glad we were able to fix it and now I can move on to bigger and better things.
I will include my code for future reference for anyone searching for a tab control example in C++ because I was never able to find an example like this anywhere on the net.
<br />
<br />
BOOL CALLBACK OptionsDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
<br />
static HWND tab1_hwnd = NULL;<br />
static HWND tab2_hwnd = NULL;<br />
static HWND CurrentTabHwnd = NULL;<br />
static int CurrentTabIndex;<br />
static HWND hwndTab = NULL;<br />
<br />
switch(msg)<br />
{<br />
case WM_INITDIALOG:<br />
{<br />
<br />
LPSTR tab1_title = "General";<br />
LPSTR tab2_title = "Advanced";<br />
<br />
INITCOMMONCONTROLSEX tabctl;<br />
<br />
tabctl.dwSize = sizeof(tabctl);<br />
tabctl.dwICC = ICC_TAB_CLASSES;<br />
<br />
InitCommonControlsEx(&tabctl);<br />
<br />
hwndTab = GetDlgItem(hwnd,IDC_TAB1);<br />
<br />
TCITEM ItemStruct;<br />
<br />
ItemStruct.mask = TCIF_TEXT;<br />
ItemStruct.pszText = tab1_title;<br />
ItemStruct.cchTextMax = sizeof(tab1_title);<br />
ItemStruct.iImage = 0;<br />
ItemStruct.lParam = 0;<br />
<br />
SendMessage(hwndTab, TCM_INSERTITEM, 0, (LPARAM)&ItemStruct);<br />
<br />
ItemStruct.pszText = tab2_title;<br />
ItemStruct.cchTextMax = sizeof(tab2_title);<br />
<br />
SendMessage(hwndTab, TCM_INSERTITEM, 1, (LPARAM)&ItemStruct);<br />
<br />
tab1_hwnd = CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_OPTIONS_GENERAL), hwndTab, General_OptionsDialogProc, 0);<br />
tab2_hwnd = CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_OPTIONS_ADVANCED), hwndTab, Advanced_OptionsDialogProc, 0);<br />
<br />
CurrentTabIndex = 0;<br />
CurrentTabHwnd = tab1_hwnd;<br />
<br />
ShowWindow(tab1_hwnd,SW_SHOWDEFAULT);<br />
<br />
<br />
}<br />
break;<br />
<br />
case WM_NOTIFY:<br />
{<br />
<br />
LPNMHDR lpnmhdr = (LPNMHDR) lParam; <br />
<br />
switch(lpnmhdr->code){<br />
case TCN_SELCHANGE:<br />
{<br />
ShowWindow(CurrentTabHwnd, SW_HIDE);<br />
<br />
switch(TabCtrl_GetCurSel(hwndTab)){<br />
case 0:<br />
ShowWindow(tab1_hwnd,SW_SHOWDEFAULT);<br />
CurrentTabHwnd = tab1_hwnd;<br />
CurrentTabIndex = 0;<br />
break;<br />
case 1:<br />
ShowWindow(tab2_hwnd,SW_SHOWDEFAULT);<br />
CurrentTabHwnd = tab2_hwnd;<br />
CurrentTabIndex = 1;<br />
break;<br />
}<br />
}<br />
break;<br />
default:<br />
return FALSE; <br />
}<br />
<br />
}<br />
break;<br />
case WM_COMMAND:<br />
{<br />
<br />
switch(LOWORD(wParam)){<br />
<br />
case IDOK:<br />
EndDialog(hwnd,0);<br />
break;<br />
case IDCANCEL:<br />
EndDialog(hwnd,0);<br />
break;<br />
}<br />
<br />
}<br />
break;<br />
case WM_CLOSE:<br />
EndDialog(hwnd, 0);<br />
break;<br />
<br />
default:<br />
return FALSE;<br />
}<br />
return 0;<br />
}<br />
<br />
<br />
|
|
|
|
|
Maybe you should combine SW_SHOWDEFAULT for current sub-dialog with SW_HIDE for the rest ones, for instance:
ShowWindow(tab1_hwnd, SW_SHOWDEFAULT);
ShowWindow(tab2_hwnd, SW_HIDE);
|
|
|
|
|