|
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);
|
|
|
|
|
i have a problem in loging in dialog box
i means i have dialog box from which i want to go next dialog box but by username and password which it confirm from mysql table
and for different pm and admin authentication
ihav dialog box which has two edit boxes one for username and one for password
so i want that when i enter username
and password then it confirm those from mysql table named user
and when i enter admin type username and passward it open one form and wheni enter pm username and password it open second dialog box
note :
mysql database may contain two tables one for users and one for authentication
Please mail me
-- modified at 4:40 Tuesday 13th June, 2006
|
|
|
|
|
Can you mention it more clearly what you have to do.....If it is login checking and showing the respective dialog then it's more easy and you should fight on it...
Cheers
"Peace of mind through Technology"
|
|
|
|
|
You should be checking the text of the boxes with the entries in the columns of the table say login(table). set a flag variable for the admin/user type.
Based on this flag value you can show the dialogs you wish to show.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
wrote: ihav dialog cbox which has tow edit boxes
Please post your problem neat and clean, It has more spelling mistakes.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
plz sombody solve my problem
i make a dialog box in mfc on which i take a date time picker control
with this control i submit the date to mysql table but my problem is that
the date is not fetched(returned) in this date time picker control AND ALL OTHER DATA IS fetched even if i take edit control i fetch date but in mysql format that is yyyy-mm-dd
tel me how i fetch date from mysql table into date time picker
note: the date is fetched which is stored on mysql table not system date
Please mail me`
|
|
|
|
|
The people in this forum have been answering your question for quite a while now.
Anyways this is hint :
Extract the date from the string.
From this string extract yyyy,mm and dd.
Now using CString::Format() again format the date and insert it into the datetime picker.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
how can i extract date from string as my code in vc++ and it give undeclared varaibe if i extract yyyy,mm and dd from my query
and how to convert into vc++ format dd-mm-yyyy
Please mail me
|
|
|
|
|
are you able to get the string from the mysql table that contains the date?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
yes but i dont know how to seprate it as i fetch a set of results
and i dont know haow to seprate date from thta qoery
Please mail me
|
|
|
|
|
yogendra kaushik wrote: yes but i dont know how to seprate it as i fetch a set of results
and i dont know haow to seprate date from thta qoery
Have you checked my last post for your question ??
i have posted the link, where you get solution for your problem.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|