|
amitmistry_petlad wrote: but Look at that very carefully , I have made it for windows not for control inside that window, I am inprocess of that but how can I find the clue that windows and controlId.
in the same code. if you might checked Mr.Paolo Messina example.
No, I'vent checked that example. But, sure that it will have same problem solution.
|
|
|
|
|
I need to spray in picture.
and need to apply cross pattern in image.
How can i do that?
|
|
|
|
|
Can you more explain spray in picture?
|
|
|
|
|
Dear All,
We need to create an application for folder selection dialog and we have creted using SHBrowseForFolder concept.Using this concept we were able to compile and run the application in Emulator.Whereas when we are trying to run the application in CEPC(x86 processor), it just hangs and shows the message as "Unknown: DEBUGCHK failed in file C:\WINCE500\PUBLIC\SHELL\OAK\HPC\CESHELL\API\.\api.cpp at line 385".It happens when the application issues the api SHBrowseForFolder.Can anyone suggest an idea to solve this problem.
Thanks in Advance.
|
|
|
|
|
Recently I study writing program about ListBox control,I ran up some diffculties.
1.I override the virtual funtion MeasureItem() to change the width of the item,I set a breakpoint in the funtion,but when I debug,the program don't run through the breakpoint.In other words,the result is that the width of the item didn't be changed:
void CMyListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
lpMeasureItemStruct->itemHeight=32;
}
2.I override DrawItem() and add an funtion to initialze the item what is factly is a string.In the funtion DrawItem() I used TextOut() to output what I initialized,but the program appeared a warning.When I run the program,the listbox's item is not the words I initialized:
void CMyListBox::PreSubclassWindow()
{
InitData();
CListBox::PreSubclassWindow();
}
BOOL CMyListBox::InitData()
{
if(m_Inited)
return TRUE;
CString s("OK");
AddString(s);
AddString("1");
m_Inited=TRUE;
return TRUE;
}
void CMyListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
....
if(nIndex != (UINT)-1)
{
//Draw th item.
InflateRect(&rect,-2,-2);
dc.TextOut(rect.left+4,rect.top+2,
lpDrawItemStruct->itemData); //warning
}
....
}
|
|
|
|
|
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);
}
|
|
|
|
|
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.
|
|
|
|