|
Hi Superman,
First thanks a lot for replying.
I have another problem, i know only the dialog name.
I don't have the handle to the updown control.
How should i find it?
Thanks in advance
|
|
|
|
|
That is exactly what FindWindowEx gives you.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks a lot.
Its working fine..
|
|
|
|
|
Hi all,
I m using a ListBox and add Variable for this that is CCheckListBox type.
there is 4 items,and i m also use a Check box that is use to select and deselct all items of ListBox.
i m handle it over ON_LBN_SELCHANGE of ListBox and Click event of Check box.
selection and deselection from Checkbox working fine.
but problem occur when i use it by List box means, iwant when the all items of list box checked than Select all Check box automatically Checked or vice-versa.
but i have one problem when i continous click on listbox its not working fine.
CButton m_sel_all_chk;
CCeckListBox m_col_lb;
void CExcel_Info_Dlg::OnBnClickedCheckSelAll()
{
if(m_sel_all_chk.GetCheck()==1)
{
for(int i=0;i<m_col_lb.GetCount();i++)
{
m_col_lb.SetCheck(i, 1);
}
}
else if(m_sel_all_chk.GetCheck()==0)
{
for(int i=0;i<m_col_lb.GetCount();i++)
{
m_col_lb.SetCheck(i, 0);
}
}
}
void CExcel_Info_Dlg::OnLbnSelchangeListColumns()
{
BOOL flag;
flag=FALSE;
int count=m_col_lb.GetCount();
for(int i=0;i<count;i++)
{
if(m_col_lb.GetCheck(i)==0)
{
flag=TRUE;
break;
}
}
if(flag==FALSE)
{
m_sel_all_chk.SetCheck(1);
}
else
{
m_sel_all_chk.SetCheck(0);
}
}
so please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: but i have one problem when i continous click on listbox its not working fine.
...
so please help me for this
Your code snippet worked fine for me.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i means when i click on List box item multiple times and all items are checked than select all check box automatically checked.
or if not checked all items select all button not checked.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I understand what you want, and the code snippet you've shown does exactly that.
In addition to what you want the code to do, you might also add what it's actually doing.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi all,
I want to read the content of the file.(say .txt)
I am using Read method...But Its not reading the entire contents present in the file rather it reads around 50% of the file.
-------------------------
Code Snippet:
CStdioFile docfile;
WCHAR* preadbuf;
if(docfile.open(....))
docfile.read(preadbuf,docfile.getlength());
------------
Please tell me how to solve this problem. please let me know if you have any queries..
Thanks,
Rakesh.
|
|
|
|
|
Does CStdioFile have open and read methods?
The length parameter to any read function is the amount of data to be read from the file.
I believe there is some mistake here.
The first parameter to the read function must be a buffer containing some memory and not just a pointer.
Look at the example in the documentation of CFile::Read[^].
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
You never allocate preadbuf, so I'm really amazed that your code doesn't crash here...
|
|
|
|
|
|
shuzh wrote: 这个东西 貌似很好弄袄
Exactly.
|
|
|
|
|
First you should make up your mind if you want to read the file line by line or read the entire file into a buffer.
In case of the former option use CStdioFile::ReadString() method, for the latter use CFile::Read() .
|
|
|
|
|
Rakesh5 wrote: if(docfile.open(....))
docfile.read(preadbuf,docfile.getlength());
This will not even compile. If you want to know why a particular piece of code does not work, at least show the actual code.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Just a thought. But here goes:
You seems to read the file as Unicode, that way every character consists of two bytes in the file.
If docfile.getlength() reports the file size in bytes, then you get your 50%.
An example, suppose the file is 50 bytes.
docfile.getlength() returns 50.
But you can read 25 Unicode characters from it.
Makes sense?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
I have a worker thread for example,
DWORD ThreadProc(void* pVal)
{
while()
{
pcEdit->SetWindowText("Status");
pcEdit2->SetWindowText("Status2");
}
}
Is it okay to update UI this way from the thread? Or how should I do? Anybody can explain in simple words?
The above actually works fine. But mate says I shouldn't do it, but he doesn't say how to do it.
----------------------------
286? WOWW!
|
|
|
|
|
The right way to do it is to post messages to the thread that owns the UI.
Use the PostMessage[^] API to post messages.
For SetWindowText post the WM_SETTEXT[^] message.
The problem that can occur is such scenarios is when both the worker thread and the thread that owns the UI simultaneously updates the control. For SetWindowText , this may not be a problem because the function does the same thing of sending the WM_SETTEXT message.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
«_Superman_» wrote: The right way to do it is to post messages to the thread that owns the UI.
You mean I should post the message straight to the control right?
«_Superman_» wrote: For SetWindowText, this may not be a problem because the function does the same thing of sending the WM_SETTEXT message.
You mean I can go ahead with myCtrol->SetWindowText()? Then which controls/APIs exactly make the problem?
----------------------------
286? WOWW!
|
|
|
|
|
_8086 wrote: You mean I should post the message straight to the control right?
No. Create a custom message and post the custom message to the UI thread.
The custom message handler in the UI thread can call SetWindowText .
_8086 wrote: You mean I can go ahead with myCtrol->SetWindowText()?
It is cleaner to send a custom message to the UI thread.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Here[^] is an excellent article you should read before starting to work with threads. It will cover a lot of important points and traps when working with thread (it also has a section answering your question).
|
|
|
|
|
I hope you've resolved the problem by now?
However, take this as a rule while doing multi-threaded programming: Never manipulate an UI element from a different thread than what owns it instead.
Like others said, post a message to the thread that owns the UI element, and have it manipulate the control for you.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
My qustion is Why this happened???
if sibling window paint by Z-order according to MSDN doc, the button should not be painted after the dialog.
http://msdn.microsoft.com/en-us/library/dd183426(VS.85).aspx[^]
--------------------------------------------------------------
Do the follow simple step you will see the "magic" button:
1. Create MFC SDI project
2. At [resouce view], Add a dialog and set style child.(WS_CHILD)
3. Add this code to the *view.cpp to create to child window:
#define BTN1 10101
int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_dlg.Create(CTestDlg::IDD, this);
m_dlg.ShowWindow(SW_SHOW);
RECT rect;
rect.left = 10;
rect.top = 100;
rect.right = 110;
rect.bottom = 125;
m_btn.Create(_T("testBtn"), WS_VISIBLE | BS_PUSHBUTTON, rect, this, BTN1);
return 0;
}
* CTestDlg m_dlg, CButton m_btn is member of the CTestView
* Z-order can be checked either by Spy++ or GetWindow API
You can fix the problem by add WS_CLIPSIBLINGS style of the button.
m_btn.Create(_T("testBtn"), WS_VISIBLE | BS_PUSHBUTTON | WS_CLIPSIBLINGS, rect, this, BTN1);
|
|
|
|
|
My guess is you should be creating the button in your m_dlg::OnCreate object, not in CTestView::OnCreate.
|
|
|
|
|
thanks, Eric Haddan
I use Button just to show the problem, it will be the same if two dialog created as child of CTestView
The problem is: because sibling window paint in z-order(not as MSDN said), window in the lower order paint latter,makes window showed, but not active.
|
|
|
|
|
Is there any easy way to shift or swap elements inside vector?
For example if I have a vector that contains:
A B C D E F
and I want to swap elements B and C to read
A C B D E F
Thanks in advance!
-Rob
Whoever said nothing is impossible never tried slamming a revolving door!
|
|
|
|