|
ups, no!
i dont have this in my Create function!!!
Here is my Create(i add BS_NOTIFY):
m_cAddNewParam.Create(L"Add new param", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_NOTIFY, cRect, pParentWnd, IDC_ADD_PARAM);
BEGIN_MESSAGE_MAP(CFileDialogEx, CFileDialog)
ON_BN_CLICKED(IDC_ADD_PARAM, OnAddParam)
END_MESSAGE_MAP()
dont work again, something else what i forgot to add?!
regards
break;
|
|
|
|
|
break; wrote: something else what i forgot to add?!
Nothing wrong with this code.
|
|
|
|
|
Hello Prasad,
i cant explain my self why my button dont run this function!!!
How do you make this? Any sample code?
regards
break;
|
|
|
|
|
break; wrote: m_cAddNewParam.Create(L"Add new param", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_NOTIFY, cRect, pParentWnd, IDC_ADD_PARAM);
It's not related to your problem, but the BS_NOTIFY style is not necessary.
The code you have will work, though. How do you have OnAddParam() defined?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Im not sure its your problem but I guess maybe its of IDC_ADD_PARAM.Anyway what happens if you run this code
#define IDC_TEST 1000
...
BEGIN_MESSAGE_MAP(Ctest1Dlg, CDialog)
ON_BN_CLICKED(IDC_TEST, OnBnClickedButton0)
END_MESSAGE_MAP()
DWORD Style=WS_CHILD|WS_VISIBLE|BS_NOTIFY|WS_EX_WINDOWEDGE|WS_TABSTOP|WS_BORDER;
m_Button.CreateEx(0,_T("BUTTON"),_T("Test"),Style,0,0,100,23,this->m_hWnd,(HMENU)IDC_TEST,0);
void Ctest1Dlg::OnBnClickedButton0()
{
MessageBox(_T("test"));
}
afx_msg void OnBnClickedButton0();
|
|
|
|
|
Hello WhiteSky,
i have exact like your sample, but dont work,
ok, is little different.
#define IDC_ADD_PARAM 1130
BEGIN_MESSAGE_MAP(CFileDialogEx, CFileDialog)
ON_BN_CLICKED(IDC_ADD_PARAM, OnAddParam)
END_MESSAGE_MAP()
BOOL CFileDialogEx::OnInitDialog()
{
m_cAddNewParam.CreateEx(0 ,L"BUTTON", L"name", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,
cRect.left, cRect.top, 100, 25, pParentWnd->m_hWnd, (HMENU)IDC_NEWPARAM, 0);
class CFileDialogEx : public CFileDialog
{
DECLARE_DYNAMIC(CFileDialogEx)
public:
CWnd m_cAddNewParam;
protected:
afx_msg void OnAddParam();
So i use other solution:
i create a new little dialog, put all controls what i need on them,
and include this dialog on my extended CFileDialog, so i have customized own CFileDialog.
For the future, i like to know why this dont work!
thanks for help
break;
|
|
|
|
|
Hi break;
If you declare CButton m_cAddNewParam; instead CWnd m_cAddNewParam; and insert BS_NOTIFY what happens?
|
|
|
|
|
Hi,
nothing happens, the same!
Ok, i think i use the solution with extra dialog with controls,
like in the answer before, that works!
thanks
break;
|
|
|
|
|
I was working with custom dialog(GetOpenFileName)and it was good.Did you check for IDC_ADD_PARAM 1130 is it a unique value ?
|
|
|
|
|
I think problem is on the detialy because if you run this code on the a project you can see a button and it response to clicks
|
|
|
|
|
Hi All,
when i call loadXML there is some memory leak.
please give me a solution to avoid memory leak.
|
|
|
|
|
voorugonda prashanth wrote: please give me a solution to avoid memory leak.
delete your pointers, or use smart pointers
|
|
|
|
|
voorugonda prashanth wrote: when i call loadXML there is some memory leak
How you are verifying this ? Can you show code ?
voorugonda prashanth wrote: please give me a solution to avoid memory leak.
Release memory allocated. As already suggested use smart pointers.
Delete memory allocated using new .
|
|
|
|
|
i displayed the filpath in my listview's first item. when I close the application its stored in xml file and when application reopen it will restore the data in the listview again through reading the xml file . when i read the data and dispaly item in the listview it will show me the UNICODE CHAR
e.g. like square box.
how can remove it please help me.
Amit
|
|
|
|
|
amitmistry_petlad wrote: it will show me the UNICODE CHAR
How can you be sure that it reads the characters in unicode ? It can simply be that you display a string that is wrong, perhaps because it failed during the load (or you did it wrong). Did you use your debugger to check if everything was as expected ?
|
|
|
|
|
when i wrote in the file it is like below
<filelist>
- <listitem type="dir" order="0">
<path>C:\Documents and Settings\Amit\Desktop\MediaFiles\</path>
</listitem>
</filelist>
then second time when i reopen and read from the file
.....<path>
C:\Documents and Settings\Amit\Desk
it is ok but then it will give three squarebox.
when i debug it is ok and display normal text but when dispaly in the listview at that time it gives square box in the listview GUI.
what should i do ?
the code is following
<pre>
if(inputtype=="dir")
{
if(tmp.find("order") != -1)
{
size_t pos1 = tmp.find_last_of("=");
string tmporder = tmp.substr(pos1 + 2);
size_t pos2 = tmporder.find_last_of("\"");
string inputorder = tmporder.substr(0,pos2);
int i=atoi(inputorder.c_str());
tok = strtok_s(NULL,"<>",&token);
tmp=tok;
if(tmp.find("path") != -1)
{
tok = strtok_s(NULL,"<>",&token);
string filename=tok;
WCHAR* DIRPATH=util.ConvertStringToWCHAR(filename.c_str());//i have done it both way with string as well as with tok but not successful
LvItem.pszText=(LPWSTR)DIRPATH;
SendMessage(hList,LVM_INSERTITEM,i,(LPARAM)&LvItem);
}
</pre>
-- modified at 22:54 Tuesday 13th February, 2007
|
|
|
|
|
amitmistry_petlad wrote: when i wrote in the file it is like below
<filelist>
<listitem type="dir" order="0"> <path>C:\Documents and Settings\Amit\Desktop\MediaFiles\
You should really use a XML-Parser instead of code it by hand.
Try TinyXML[^] or CMarkup[^]
Are you sure your ConvertStringToWCHAR() is working as expected?
In the Debugger, DIRPATH and filename look the same?
You are setting pszText , but not setting the mask accordingly.
Are you sure LVM_INSERTITEM can cope with unicode? I am not, but I never tried. it.
Wouldn't it be easier to use the CListCtrl s member InsertItem() ?
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach wrote: Are you sure your ConvertStringToWCHAR() is working as expected?
1)yes.ConvertStringToWCHAR() its working
jhwurmbach wrote: In the Debugger, DIRPATH and filename look the same?
2)yes. at the time of debugging i have checked it .both same .
jhwurmbach wrote: You are setting pszText, but not setting the mask accordingly.
is it must?
jhwurmbach wrote: Wouldn't it be easier to use the CListCtrls member InsertItem()?
i will try it out.
but i am using win32 .ok
jhwurmbach wrote: Are you sure LVM_INSERTITEM can cope with unicode? I am not, but I never tried. it.
that i dont know
|
|
|
|
|
amitmistry_petlad wrote: jhwurmbach wrote:
You are setting pszText, but not setting the mask accordingly.
is it must?
Thats how I read the doku.
In mask you set which of the items are to be regarded as valid.
amitmistry_petlad wrote: jhwurmbach wrote:
Wouldn't it be easier to use the CListCtrls member InsertItem()?
i will try it out.
but i am using win32 .ok
Win32. Ok, no MFC functions then.
pszText is of type LPTSTR , that does mean it is char* when UNICODE is not defined and wchar_t* when UNICODE is defined.
That corresponds to your logic?
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
what should i write instead here?
if(tmp.find("path") != -1)
{
tok = strtok_s(NULL,"<>",&token);
string filename=tok;
WCHAR* DIRPATH=util.ConvertStringToWCHAR(filename.c_str());
<code> LvItem.pszText=(LPWSTR)DIRPATH;</code>
SendMessage(hList,LVM_INSERTITEM,i,(LPARAM)&LvItem);
}
|
|
|
|
|
Are you compiling your project with UNICODE defined?
the std::string filename you use is certainly not Unicode-capable. You would need std::wstring.
Then your function ConvertStringToWCHAR is giving out a pointer. Hwo is owning the memory there? Who does delete it? Are you sure it is valid at the point of SendMessage?
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
ya i had checked. configuration property->general->Character Set Use Unicode Character Set.
even if i will not use string then also i can use tok.
so it is better to me to use tok.because its char *
2) when i select the path like.
c:\documents and setting\...\desktop
and when close the application it goes the properway in XML.
but when i reopen it the blank space of documents and settings will be deleted and the character has been shifted that place means the blank space is fill by the next char and when it comes at the end desktop,
it will display like desksquaresquaresquare
WCHAR* Utility::ConvertStringToWCHAR(string source)
{
try
{
WCHAR w_Out[MAX_PATH];
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,source.c_str(),(int)(source.length() + 1),w_Out,MAX_PATH);
return w_Out;
}
catch(exception ex)
{
throw ex;
}
}
|
|
|
|
|
Your ConvertStringToWCHAR function returns a pointer to a stack-variable:
With the closing bracket of the try-block, w_Out goes out of scope. It is undefined what happens with the memory formerly being w_Out . So the pointer may or may not point to complete rubbish.
And the length-parameter for the int-string is surely source.length() , not lenght()+1 ? Since length() is giving the number of chars in the string.
Please chek the return-value from MultiByteToWideChar() , and output GetLastError when it is 0.
Also, you could try to call MultiByteToWideChar() with the last parameter ccWideChar being 0 , and glean from the return value how many wide chars you need to provide.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
please edit your message and put your codes samples withing a <pre></pre> tags block...
|
|
|
|
|
Hi..
I am creating an ActiveX control..and I have to set the Threading Model to both
'afxRegApartmentThreading' and 'afxRegFreeThreading' in the function
'AfxOleRegisterControlClass' in VC++ 6.0
But, the compiler gives an error...."'afxRegFreeThreading' : undeclared identifier"...
I have checked in MSDN...this 'afxRegFreeThreading' is a valid parameter..
Whats wrong here?
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|