|
IT_DOER wrote: return CListBox::PreCreateWindow(cs);
Here this line is unnecessary. Change it to return TRUE;
You need to mention what warnings are generated by compiler. And if your list box is Ownerdrawn, MeasureItem should be called.
|
|
|
|
|
the warning's content is this:
warning C4244: 'argument' : conversion from 'unsigned long' to 'char', possible loss of data
I have tried many methods of initializing the data,for example,
BOOL CMyListBox::InitData()
{
if(m_Inited)
return TRUE;
CString s("OK");
AddString(s);
//or
//AddString((LPCTSTR)s);
//or
//AddString("OK");
m_Inited=TRUE;
return TRUE;
}
Whether I shouldn't use the TextOut to output the data?
I have checked that the listbox's properties of "OwnerDraw" is set "Fixed",however,I don't know why the MeasureItem don't be called.
|
|
|
|
|
IT_DOER wrote: warning C4244: 'argument' : conversion from 'unsigned long' to 'char', possible loss of data
First, get CString* from itemdata and then use it in function.
IT_DOER wrote: I have checked that the listbox's properties of "OwnerDraw" is set "Fixed",
In this case, MeasureItem will be called once.
Why dont you refer ListBox[^] section on CP ? You will find example owner drawn list box.
|
|
|
|
|
my god~~I can't work it out yet.I initialized the data like this:
CString s("OK");
AddString((LPCTSTR)s);
and I use it like this:
.....
CString* pt_str=(CString*)lpDrawItemStruct->itemData;
.....
dc.TextOut(lpDrawItemStruct->rcItem.left+4,lpDrawItemStruct->rcItem.top+2,pt_str) //ERROR
D:\MyCode\ChangeCtrlClr\MyListBox.cpp(77) : error C2664: 'int __thiscall CDC::TextOutA(int,int,const class CString &)' : cannot convert parameter 3 from 'class CString *' to 'const class CString &'
the funtion TextOut needs a parameter of "const CString& str", do it needs a point to a CString object?Isn't "pt_str" a point to it?
And I am new here,I don't know what is CP..
Thanks a lot.
|
|
|
|
|
IT_DOER wrote: CString* pt_str=(CString*)lpDrawItemStruct->itemData;
.....
dc.TextOut(lpDrawItemStruct->rcItem.left+4,lpDrawItemStruct->rcItem.top+2,pt_str) //ERROR
I think, you are just missing simple C++ thing. Need to listen carefully to compilere.
In this case you are passing pointer where, object reference is needed.
Just modify your code to,
CString* pt_str=(CString*)lpDrawItemStruct->itemData;
.....
dc.TextOut(lpDrawItemStruct->rcItem.left+4,lpDrawItemStruct->rcItem.top+2,*pt_str);
IT_DOER wrote: And I am new here,I don't know what is CP..
Refer[^] this link to get faster answers.
|
|
|
|
|
prasad_som wrote: I think, you are just missing simple C++ thing. Need to listen carefully to compilere.
In this case you are passing pointer where, object reference is needed.
I am a student who is a junior in using and like VC++.Well,I will strengthen the basic knowledge of C++.
I modified the code to what you wrote,but when I ran the program,the system poped up a dialog that said there is someting wrong in the program and it need to be closed.And if I set the ListBox'style of OwnerDraw to NO,the program could run normally. Whether I used the pointer incorrectly?
|
|
|
|
|
Check the CString* for NULL . If its NULL you should not dereference it.
|
|
|
|
|
I forgot to tell that I have set the ListBox' properties:
BOOL CMyListBox::PreCreateWindow(CREATESTRUCT& cs)
{
if(!CListBox::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle |=WS_EX_CLIENTEDGE;
cs.style &= ~(LBS_OWNERDRAWVARIABLE | LBS_SORT);
cs.style |= LBS_OWNERDRAWFIXED;
return CListBox::PreCreateWindow(cs);
}
thans very much!
|
|
|
|
|
IT_DOER wrote: to change the width of the item
IT_DOER wrote: void CMyListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
lpMeasureItemStruct->itemHeight=32;
}
Are you changing width or height?
IT_DOER wrote: void CMyListBox::PreSubclassWindow()
{
InitData();
CListBox::PreSubclassWindow();
}
Are you subclassing your ListBox? if so please provide the code.
IT_DOER wrote: void CMyListBox::PreSubclassWindow()
{
InitData();
You are not supposed to add string from the control itself.
And in your reply, you mentioned about an error (unsigned long to char), this is nothig to do with your mesure item method..
Do your Duty and Don't expect the Result
|
|
|
|
|
Parthi_Appu wrote: Are you changing width or height?
OH~I made a mistake,actully I want to change the height of the item.
Parthi_Appu wrote: Are you subclassing your ListBox? if so please provide the code.
Mm..Could you explain what subclassing mean and the funtion PreSubClassWindow exactly?I don't quite understand them.
Parthi_Appu wrote: You are not supposed to add string from the control itself.
That how should I do?And the MeasureItem haven't been called.
|
|
|
|
|
IT_DOER wrote: what subclassing mean
Process window message with out sending those message to actuall control(window). That is, if you have a listbox which is working great. You want to block some of its message to process, then you have to subclass this control(window).
No need for PreSubClassWindow, so you can very well remove this.
In your derived ListBox class, handle PreCreateWindow, MeasureItem and DrawItem this will do.
In some dialog or window, you will have this derived listbox member,there, after creating the derived listbox, use AddString API.
Do your Duty and Don't expect the Result
|
|
|
|
|
Mm,I add a windows message handle WM_CREATE and call the funtion to initialize in it.What I have done is same to what you tell me,but the MeasureItem haven't been called.Maybe I need to refer to some program about ListBox.Thank you very much!!
|
|
|
|
|
Hello!Guys!!
In MFC,I want to make a users'interface.But something has blocked me.How can I use WM_MOUSEMOVE to move a bitmap in a splitted window,from left one to right one? Thank you!
|
|
|
|
|
hcygxr2008 wrote: something has blocked me
Whats your excat problem?..
hcygxr2008 wrote: How can I use WM_MOUSEMOVE to move a bitmap in a splitted window,from left one to right one?
Seems you want to draw a bitmap from left pane (left side view) to right pane under some condition ( WM_MOUSEMOVE ). To do this, you have to notify the appropriate pane to draw the bitmap( custom messages will do ).
If you want to remove the bitmap in the current pane then you have repaint the pane.
Make sure both the panes have the bitmap detail.
Hope i understood your question...
Do your Duty and Don't expect the Result
|
|
|
|
|
Thank you very much! Firstly,you understood my question,But I can't understand your reply. Maybe I am poor,then,can you give me a example or just a segment of code.Thank you!!
|
|
|
|
|
Hope you know what is a custom message, if not refer SendMessage and PostMessage.
You will have a bitmap to draw, so notify the other pane to draw this bitmap if your condition met, you can use GetPane(..) API of splitter control class to get the appropriate window and send custom messages to that window,say hWnd is the handle to the window, that you have to paint the bitmap then
::SendMessage(hWnd, CUSTOM_MGS, wParam, lParam);
wParam and lParam are values that you can pass to the destination window, you can make use these params to send the bitmap information.
Handle the message in the destination window, refer ON_MESSAGE macro for message map entry. Use the bitmap information that you have sent in wParam or lParam and then draw the bitmap.
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
Thank you for your help! I will try what you have said!!If I met any difficulty,hope you can help me . Thank you again!
|
|
|
|
|
If my program running by current user (for example, administrator or user), when turn off windows, that no problem. But if my program running by system user, when turn off windows, windows would open a error dialog.
How to solve this problem. Thanks.
|
|
|
|
|
Hi all
I have to read a comma seperated value text file. But i am not able to get it to work
Can any one help me out in this. Or if any one could show me some reference code.
The text is some what like this
bond,james,23,oxfordstr,canterbury,23421,abc@yahoo.com,82710120
Any or all help would be greatly appreciated.
ps note=> I couldnt not find any good article over this issue.
|
|
|
|
|
|
As folks responded to you previously, you can do this with strtok() (prototype in "string.h"), and as this is in my copy of Kernighan and Ritchie, I suspect it is supported in Borland.
If you want a packaged parser with source code, look at the link provided by ThatsAlok in replying to your previous post of the same question.
It's also amazing what you seem to find if you google on "c++ csv parser"...
-- modified at 21:10 Monday 19th March, 2007
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Software_Specialist wrote: But i am not able to get it to work
Can any one help me out in this. Or if any one could show me some reference code.
http://www.koders.com/default.aspx?s=csv&btn=Search&la=Cpp&li=*[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Software_Specialist wrote: But i am not able to get it to work
Why not? What have you tried?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
whoa.... four answers at the same time? we may have just exploded his brain with choices.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Jeffry J. Brickley wrote: four answers at the same time? we may have just exploded his brain with choices.
I had a fifth (ODBC), but my machine is not configured to test such a suggestion.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|