|
What I've done in the past is a bit complex, but a lot simpler than wiring up an HTML control - especially in Win32.
1/ Make a big overall window. Maybe a dialog box... The choice is up to you.
2/ Place a group control on it. This is just decoration.
3/ Place a vertical scroll bar next to, or just inside the right edge of the group box.
4/ Handle messages from WM_VSCROLL in your parent (eg) dialog.
5/ Create a child window taking up most of the space inside the group control. We'll call it PaneParent. This is blank, and does nething interesting except...
6/ Create a child window (call it Pane) inside the above child window. This Pane can be very large, and was also a modeless dialog box (with the WS_CHILD style set).
7/ When the scroll bar is used, move the Pane window about inside PaneParent. PaneParent will clip the Pane, so you only see a part of it.
Caveats - you'll also want the CONTROL and CONTROLPARENT styles set, to help the TABbing about.
None of this is easy, but it's OK if you break it into simpler bits. Make a dummy dialog with "I'm the top!", "I'm the middle!" and so on static controls on it until you have things working a bit more. But it's still easier than handling callback interfaces from an embedded browser control...
Iain.
|
|
|
|
|
gayatri.neelema wrote: I want to have a scroll bar for a group-box control.
Isn't a group box supposed to be static? How did you get this bad idea?
Why do you want to keep in so many things such that you will need a scroll bar? Not only will it require extra coding efforts, but it will look terrible. Ever heard of a tab control?
gayatri.neelema wrote: I know this can be done in MFC , but i dont know whether the same can be done in win32 also.
Yes.
gayatri.neelema wrote: Could any one help me
No, not for attaching a scroll-bar to a group box.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
How can we a tab control be useful,
I am clueless about it.
I have lots of data to be displayed in a dialog , could you please help me
|
|
|
|
|
Rajesh's idea is a good one - mine was just telling you how to do something.
But his point is good. If you really have tons of stuff there, can you break it into sections? If so, read up on property sheets / property pages. Window's uses those in the control panel.
And MFC has CPropertyPage/Sheets all ready and waiting for you when you come back from reading.
Iain.
|
|
|
|
|
gayatri.neelema wrote: could you please help me
Of course yes, but read up on tab control (there are plenty of samples all over the internet) and if you encounter a trouble, come back and post what do you need help with.
It is not a very daunting task, if you ask me.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Create a group box with WS_VSCROLL style.
|
|
|
|
|
Hi,
I am working on an mfc application and implementing chat module. In chat module i need to give the function of sending emoticons. I am using a button with text emticons and when i click it i am opening a dialog box which is having several smiley.
Now the problem is that I want open the DialogBox having emoticons just above the button having text as emoticons. How can i position my DialogBox at just top of the button.
Thanks In Advance.
Dhiraj Kumar Saini
|
|
|
|
|
Make the coords of the button available to the dialog and then use SetWindowPos [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Please if u dont mind let me know how to get the coordinates of a button control.
Thanks.
|
|
|
|
|
GetWindowRect(), ScreenToClient() and things like that...
Just attempt to use the documentation. That will be the first step.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Well, in the chat window class (say CMyChat ):
(1) define a (public ) accessor for button coordinates, for instance,
CRect GetMyButtonRect();
(2) pass the this pointer to the dialog constructor, i.e.
CMyDialog myDlg(this);
Hence the dialog is able to get Button coords:
CMyChat * pParent = reinterpret_cast< CMyChat *> (GetParent());
CRect rcButton = pParent->GetMyButtonRect();
BTW: to retrieve button coords, use CButton::GetWindowRect() method.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
when debug my program, an error happens: Unhandled exception in **.exe (user32.dll) : 0xC0000005: Access Violation.
the stack information showed as follows:
USER32! 77d3e176()
USER32! 77d2927b()
USER32! 77d3a193()
USER32! 77d2c89a()
USER32! 77d306ec()
USER32! 77d18709()
USER32! 77d187eb()
USER32! 77d1c00e()
USER32! 77d1e366()
CWnd::DefWindowProcA(unsigned int 332, unsigned int 0, long 458752) line 1000 + 32 bytes
CWnd::WindowProc(unsigned int 332, unsigned int 0, long 458752) line 1586 + 26 bytes
AfxCallWndProc(CWnd * 0x0013b0a4 {CSkinComboBox hWnd=???}, HWND__ * 0x0016048e, unsigned int 332, unsigned int 0, long 458752) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x0016048e, unsigned int 332, unsigned int 0, long 458752) line 368
AfxWndProcDllStatic(HWND__ * 0x0016048e, unsigned int 332, unsigned int 0, long 458752) line 57 + 21 bytes
USER32! 77d18709()
USER32! 77d187eb()
USER32! 77d1b743()
USER32! 77d1e2f7()
CComboBox::FindString(int 0, const char * 0x00070000) line 746 + 26 bytes
CDlg::Fun1() line 599 + 20 bytes
CDlg::Fun2() line 408
_AfxDispatchCmdMsg(CCmdTarget * 0x0013a4a0 {CDlg}, unsigned int 1116, int 1, void (void)* 0x00ac1541
but my codes is:
if (dwOldItemData != 0)
{
//error place, but not every time. and comboSource is a CSkinComboBox object
int nNewSel = m_comboSource.FindString(0, (LPCTSTR)dwOldItemData);
if (nNewSel != LB_ERR)
{
m_comboSource.SetCurSel(nNewSel);
return;
}
}
so, what's the problem? thk u!!!
|
|
|
|
|
What is the type of dwOldItemData (seeing the dw prefix I would guess a DWORD but that seems really strange) ? Why do you need to cast ?
|
|
|
|
|
yes,
DWORD dwOldItemData = 0;
because the codes will be run in linux OS, so i wrote a CSkinComboBox class by myself:
int FindString( int nStartAfter, DWORD dwAddData );
thk u again!!
and then, the problem is ..?
|
|
|
|
|
kaviniswell wrote: because the codes will be run in linux OS
You can't run your code on Linux: MFC is not cross-platform.
Furthermore, the FindString function accept a LPCTSTR string as second argument, so you can't 'simply' cast a DWORD to a LPCTSTR. That's why it crashes.
BTW: did you vote my previous answer down ? If yes, why ? I needed more information in order to help, what's the problem wiht that ?
|
|
|
|
|
sorry,i didnot know what it was,so i choose ...
yes, i know mfc cannot used in linuxos, so we wrote a similar combobox and other classes which we called xfc.and then we used xfc in linux/windows and other os.
thk u again!
|
|
|
|
|
Why don't you use an existing cross-platform GUI library instead of doing it all yourself. Take a look at wxWidgets[^] for instance, it will save you a lot (but really a lot) of pain...
For your problem, I don't understand why you are passing a DWORD to the function . Read the function documentation: the second argument is a string that is used for the search, so I really don't understand why you pass the DWORD. What did you have in mind, what are you trying to do ?
|
|
|
|
|
yes,wxWidgets is well good,but for us,there are some other problems, so we decided to do it ourselves.
why use DWORD? there are some other causes...
and i think this is not the key of this question now, is it?
thk u again!
|
|
|
|
|
kaviniswell wrote: and i think this is not the key of this question now, is it?
Of course it is. That's the core of your problem: you are using the FindString function in a complete erroneous way because of that. And that is the reason why it crashes. You already got a reply that could fix your problem: pass a string and not a DWORD (and try to avoid casts at all costs, because they let you do wrong things like you just did).
kaviniswell wrote: yes,wxWidgets is well good,but for us,there are some other problems, so we decided to do it ourselves.
I think it was a bad choice. Making cross-platform GUI is something extremly complex. Much more complex than trying to fix a problem you had with it. Why didn't you focus on that instead ?
|
|
|
|
|
yes, maybe u are right.
ok, the codes:
int CComboBox::FindString( int nStartAfter, DWORD dwItemData )
{
CListBox *pcListBox = GetListCtrl();
int nIndex = pcListBox->FindString( nStartAfter, dwItemData );
return nIndex;
}
int CListBox::FindString( int nStartAfter, DWORD dwItemData )
{
int nCount = GetCount();
if ( nCount <= nStartAfter )
return LB_ERR;
int nIndex;
for( nIndex=0; nIndex <= nCount; nIndex++ )
{
if ( GetItemData( nIndex ) == dwItemData )
break;
}
return ( nIndex == nCount ? LB_ERR : nIndex );
}
then what is the problem? i will be crazy now...
|
|
|
|
|
Wait a minute, I have a serious doubt: in fact you are not using MFC at all ? I thought that you were using MFC (because CComboBox is an MFC class with a FindString method).
If that is the case, I think you will have to debug a bit more in details because it will be difficult to help you without more concrete information. Use your debugger and just before the point of the crash, try to inspect all the variables to see if something is wrong or not...
|
|
|
|
|
Hi Cedric,
I still feel that he is using MFC. if not control should go to his implementation of CSkinComboBox::FindString and not the CComboBox. I tried using MFC and passing DWORD i get exactly same stack trace.
Regards,
Sandip.
|
|
|
|
|
Did you write a cross platform GUI library? Congratulations!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
not me but "us", and i just a freshman.
thk u again!
|
|
|
|
|
Well 'you' meant 'your group'.
Since in Italy we distinguish between 'tu' (i.e. 'you' as 'kaviniswell the freshman') and 'voi' , (i.e. you as 'the team wherein kaviniswell is a freshman'), I would say "Congratulations to voi!"
BTW: since your team looks very skilled, why don't you ask them too?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|