|
Hello,
Has anyone figured out how to make a CScrollView (or better yet a CFormView) work with a CHeaderCtrl? When I try it, the header scrolls with the view, instead of staying put like a good header should.
In my application, each row is a dynamically created child window, a bit like a modeless dialog, containing child controls. With CFormView, I just attach my child windows to the view, using SetParent, and they become part of the form; when I scroll the view, the child windows automatically scroll too. It's magic.
You may be wondering, why don't I use an ownder-drawn CListView? The header would be easy then. All of my rows are the same height, so it makes sense, but it doesn't work: when I scroll the list, my child windows don't get painted, no matter what I do. I tried attaching my child windows directly to the view's CListCtrl, instead of to the view, but it didn't help.
Any advice would be greatly appreciated!
~CK
|
|
|
|
|
The Header should not be the child of CFormview , make it child of mainframe and handle onsize event in mainframe to size header and formview so that they are both visible.
it works
|
|
|
|
|
Thank you! The fix almost works, but there's one serious problem. About half the time, when I press Alt-N to create a new document, the view overwrites my header. Would it help if I sent you my test project? At this point it's just a few lines really.
Also I don't understand why my CHeaderCtrl's captions displaying in bold instead of the usual system font? I assume CListCtrl does something that I'm not doing, but I can't figure out what.
~CK
PS here's my OnCreate and OnSize code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create header control
CRect r;
GetClientRect(r);
r.bottom = HEADER_HEIGHT;
m_Hdr.Create(WS_CHILD | WS_VISIBLE, r, this, 0);
HDITEM hdi;
const cols = 3;
LPCSTR str[cols] = {"Volume", "Pan", "Pitch"};
int wid[cols] = {172, 172, 172};
hdi.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT;
hdi.fmt = HDF_LEFT | HDF_STRING;
for (int i = 0; i < cols; i++) {
hdi.pszText = (char *)str[i];
hdi.cchTextMax = strlen(str[i]);
hdi.cxy = wid[i];
m_Hdr.InsertItem(i, &hdi);
}
return 0;
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
// shrink view vertically to make room for header
CView *vp = GetActiveView();
if (vp != NULL) { // need this or it crashes
CRect r;
vp->GetWindowRect(r);
ScreenToClient(r);
r.top += HEADER_HEIGHT;
vp->MoveWindow(r);
}
// stretch header horizontally to fill our client area
if (IsWindowVisible()) { // need this or it crashes
CRect r, cr;
GetClientRect(cr);
m_Hdr.GetWindowRect(r);
ScreenToClient(r);
r.right = cr.right;
m_Hdr.MoveWindow(r);
}
}
|
|
|
|
|
try to create a brand new font via LOGFONT and the set it using setfont and keep cfont a member of mainframe
should work
regarding ctrl-N ,
i would create two new windows in CView as the cviews child
one the header and other the window that you want and the ndo the scrolling in window not in cview this would be safe against ctrl-n
but you can modify onNewDocument to suit ur needs
|
|
|
|
|
Hi,
Are the arrows keys added automatically by a CTabCtrl ?
If so, how can I handle arrows keys added by MFC when I have multiple tabs ?
Thanks,
Claude
|
|
|
|
|
No, they are not. The number keys can be automatically added to the tab control, though..
When the tab control has focus and you press an arrow key, an event message WM_KEYDOWN is sent to the parent window.
Handle this message to interpret the pressed key, and if it is an arrow key, determine the correct tab to show, and order the tab control to show it. It is much like handling a user's mouse click on a tab of the tab control. You just do it programmatically.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
now I'm working on a project like voice chat ,I have finished voice chat when the two chatters
are both online. if one is not online what shoudl I do? so I want to record voice to a wave file
and transmite it to the other,so he can play sound.fortunately I have realized. then I think the
idea that transmiting and recording voice to a wave file at the same time when a chatter speaks
to all whether they are online or not is practical? please help me!!!!!
record and transmite voice
|
|
|
|
|
|
i created an SDI with several dialogs within for my project. Each time user input data into certain dialog, my Onpaint() in view class will show the image in the main window. It is more of like reading in user inputs and visualizing images at every dialog stage. Problem is, how do i control when to show the image? ie, i only want the Onpaint() to draw when dialog is receiving inputs instead of at beginning of program where of course my dialog is not activated yet. Also, i intend to put my drawing code in the various dialog.cpp files and call my those drawing fucntions in the onpaint(), is it the right approach? will appreciate if anyone can help
|
|
|
|
|
Within your OnPaint handler, you can test for the existence of the dialog boxes before executing your drawing code.
|
|
|
|
|
i am not very proficient in programming so can tell me how can i code that supposing my dialog is called dialog A? thank you
|
|
|
|
|
hi
i need to know how can i extract a clip of specific duration out of an avi file
|
|
|
|
|
Because macros are preprocessed prior to code execution, is it possible to change the value of a variable that a macro uses, after the program has started? Here's sample code.
#define ADD_THIS_COMMAND(f, d) CMD_FUNCTION(f); SymCommand cmd_##f(#f, d, f) Is it possible to change (by way of the program) what 'd' in the macro represents, after the program has started? (For example, if 'd' at the beginning, symbolizes the word, "Dollars", could you afterwards from inside the program change it so that the next time the macro gets executed, it would symbolize, "Pesos"?)
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
Macros are always a sign of a bad programmer, or a bad design - Bjarne Stroustrup.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
That's fine for Stroustrup to say. He is not down there in the trenches with his sleeves rolled up, handling the dirt and the mud.
William
Fortes in fide et opere!
|
|
|
|
|
WREY wrote:
He is not down there in the trenches with his sleeves rolled up, handling the dirt and the mud.
That's because he has less dirt and mud to deal with - he doesn't use macros )
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hello,
It's NOT possible to change the macro or anything that has to do with the macro (the compiler never sees the macro)! There's a simple explanation for that.
exemple:
you have this code
<br />
#define MACRO(a) cout << a << endl;<br />
MACRO("zzz")<br />
MACRO("bla")<br />
MACRO("drink coffee")<br />
after preprocessing, the code go's to the compiler. The code the compiler sees is:
<br />
cout << "zzz" << endl;<br />
cout << "bla" << endl;<br />
cout << "drink coffee" << endl;<br />
Hope this helps
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Thanks for replying.
The more I think about it, the more you make sense about what you said. Thanks.
William
Fortes in fide et opere!
|
|
|
|
|
i want to get some information about a remote machine.
so wmi(Windows Managment Instruments) can provide what i want.but i don't if it can access wmi on a remote machine outside of lan network by ip.
who can tell me?thanks?
Habbit--Beginner In MFC
|
|
|
|
|
I have Visual c++ dialog application . once the dialog has been created immediately I need to show a File Dialog .
Doing it in OnInitDialog doesnt work as expected as it pops up the file dialog .
Is there some other point where i can make this call
or do i have to have some internal variable that a timer checks after a while and then shows the dialog ?
Engineering is the effort !
|
|
|
|
|
Well there's a few ways to tackle this problem. Indeed you could use a timer. But the most important thing for you to understand is how message queues in Windows work. However, first the answer to your question. Try creating your own custom message ad handler for it first therefore at the top of your dialog CPP file...
#define WM_MYOWNMESSAGE WM_USER + 1001;
... Then in the header file put...
afx_msg LRESULT OnMyOwnMessage(WPARAM wParam, LPARAM lParam);
...Then the appropriate body for it...
LRESULT CMyDialog::OnMyOwnMessage(WPARAM wParam, LPARAM lParam)<br />
{<br />
... Show the file dialog box (I know it has to be modal)<br />
return 0;<br />
};
... And finally in the body put...
ON_MESSAGE(WM_MYOWNMESSAGE, OnMyOwnMessage)
... in the BEGIN_MESSAGE_MAP section...
... To call the message handler put this in the OnInitDialog function just before it returns...
PostMessage(WM_MYOWNMESSAGE, 0, 0);
So okay, this should work. But why should this work? You could do the same thing with a timer (Its another message WM_TIMER). Well as you well know OnInitDialog gets called when all the handles for all the windows you are creating are created but not shown. We post a custom message on to the message queue of the dialog box. This eventually gets processed. As I'm placing it on the message queue in OnInitDialog it will only get processed after this point in which the dialog box will be shown. I'm sure there are other ways but I find this one works very well for me :!)
|
|
|
|
|
typedef DWORD (WINAPI* ProcGetModuleFileNameEx)(HANDLE,HMODULE,LPTSTR,DWORD);
ProcGetModuleFileNameEx pfnGetModuleFileNameEx = (ProcGetModuleFileNameEx)GetProcAddress( hModule, "GetModuleFileNameEx" );
GetLastError = ERROR_PROC_NOT_FOUND!!!
The hModule is valid, I can get other functions addresses allright but this one is not working... Any idea??
Thanks!
---------------
Tired of Spam? InboxShield for Microsoft® Outlook® 2K/2K2/2K3
http://www.inboxshield.com
|
|
|
|
|
Ok,
using "GetModuleFileNameExA" is working, but is this safe??? My app isn't supporting Unicode since I have to support good ol' Win 98
---------------
Tired of Spam? InboxShield for Microsoft® Outlook® 2K/2K2/2K3
http://www.inboxshield.com
|
|
|
|
|
There are just the "A" and "W" versions of routines that need character strings. What you did was correct.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Is there a way to determine the size of the rendered content of a CDHtmlDialog?
- Rob
|
|
|
|