|
Hello,
I am a newbie to MFC programming in VC++. I can't seem to create more than one splitter in my MFC application.
I need to create a window similar to windows explorer but on the right I want 2 panes not 1. So instead of the right pane I want 2 horizontal panes (one on top of the other). Ultimately what I want to do is:
1)display a directory tree in the left pane
2)display files and/or directories (of selected directory from tree) in the right-top pane.
3)display contents of selected file (from above pane) in right-bottom pane.
So I can get the first vertical splitter - Visual Studio actually makes it for me cause in the application creation wizard, under visual interface features, for toolbars i selected "standard docking" with "browser style". But I can't seem to add another one.
I would appreciate if anyone could tell me how to code for this second splitter and where to code this (what class and function).
TraileR ParK LifE 4Ever >:{
|
|
|
|
|
Add another CSplitterWnd variable to your CMainFrame class, e.g. m_RightSplitter.
Replace CMainFrame::OnCreateClient with code similar to:
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}
if( ! m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), pContext) )
return(FALSE);
m_RightSplitter.CreateStatic( &m_wndSplitter, 2, 1, WS_CHILD | WS_VISIBLE, m_wndSplitter.IdFromRowCol(0,1) );
if( ! m_RightSplitter.CreateView(0, 0, RUNTIME_CLASS(CTopRightView), CSize(100, 100), pContext) ||
! m_RightSplitter.CreateView(1, 0, RUNTIME_CLASS(CBottomRightView), CSize(100, 100), pContext) )
{
return(FALSE);
}
|
|
|
|
|
Hi Bill,
Thanks for the reply. When I try your code I get these errors :
error: C2039: 'classCTopRightView': is not a member of 'CTopRightView'
error: C2065: 'classCTopRightView': undeclared identifier
<<another 2="" errors="" like="" above="" but="" relating="" to="" cbottomrightview="">>
I added CTopRightView and CBottomRightView as 'Generic C++ classes' (did not code them though - dont know how ). I have no idea why its adding the word 'class' in front of the 2 class names.
TraileR ParK LifE 4Ever >:{
|
|
|
|
|
They have to CWnd derived classes - most likely derived from CView. In addition they also have to have DECLARE_DYNCREATE in the class header file and IMPLEMENT_DYNCREATE in the class source file. If you look at the default CView classes created for the project you will see these lines.
Use "MFC Class" to create the classes instead and derive them from CView. It will then put these lines in automatically for you.
The "classCTopRightView" is a special member variable that MFC puts in for runtime class typing and dynamic creation. It uses the name "classCYOURCLASSNAMEHERE" as the member name. The above macros put these in for you.
|
|
|
|
|
WOW! It worked! Thanks a lot, really appreciate it... not many people help out on their own time, thanks greatly again!
TraileR ParK LifE 4Ever >:{
|
|
|
|
|
I am trying to use a grid control with a combobox in one
of the fields. it works with CDialog but it does not work
with CFormView
I did exactly like it says here
http://www.codeproject.com/listctrl/nirs2000.asp
exept I used it with CFormView
and when I click a fild twice(not double click the clicks
can be minutes apart)
it crashes saying something about wincore.c
and it gives me a messagebox with abort retry ignore
I can provide the source for anyone that might want to
help me.
thank you all in advance
excuse me for my bad english
|
|
|
|
|
Hi, I want to open the system menu of a window from code instead of as usual letting the user do it by right mouse-clicking on the top left icon. I use GetSystemMenu() to get the system menu and TrackPopupMenu() to display it. The system menu shows up but when I click on any menu item, nothing is routed back to the window. OnSysCommand() which normally receives system menu clicks is not called. However if the system menu is opened by the user as usual, everything works fine. What do I do wrong? How do I trap the menu item clicks?
Here’s the code from my test project, a standard dialog based application, TestDlg inherits from CDialog so this pointer is the dialog itself with the OnSysCommand() method.
void TestDlg::OnButton()
{
CMenu* pSysMenu = GetSystemMenu(FALSE);
pSysMenu->TrackPopupMenu(0, 100, 100, this);
}
/Thanks, Patric
/Patric
My C# blog: C# Coach
|
|
|
|
|
Try this instead:
void TestDlg::OnButton()
{
SendMessage( WM_SYSCHAR, VK_SPACE, 0x20000000 );
}
|
|
|
|
|
Thanks, it works.
/Patric
My C# blog: C# Coach
|
|
|
|
|
hey, im using visual studio 2003 and im coding this program in visual c++ .net. i compiled my program and made a release build, it runs on my pc, but it cant run on other peoples system, i cant figure out why, they are just getting the CLR error and i dont know how to fix it for them to run my program, any advice guys?
|
|
|
|
|
|
yes, they have 1.1 and 2.0 installed and still the CLR error comes up
|
|
|
|
|
okay, now its about the 'system.security.securityexecption' error, how do i allow other users to use my program as in give them permission?
|
|
|
|
|
Hi everybody. Long time no posting. Been busy working at the freeware Application and I'm almost done with the first beta : ). Also, I'm preparing an article for the Code Project. Anyway, I posted this message to see if any of you got any clue about the following problem:
Grabbing the DC of a window, copying it in a memory DC, drawing something (like a square for example) and then BitBlt-ing the result in the original window whenever you wish.
Take a look at this short code. It's supposed to grab a window DC and put it in a memory DC and return a handle to a DDB. It's from a book. My problem is that I want to do something similar, but I can't make it work. My experiments are kind of failed... so I won't post them. Here's the original code:
HBITMAP CaptureWindow(HWND hWnd)<br />
{<br />
RECT wnd;<br />
<br />
if ( ! GetWindowRect(hWnd, & wnd) )<br />
return NULL;<br />
<br />
HDC hDC = GetWindowDC(hWnd);<br />
<br />
HBITMAP hBmp = CreateCompatibleBitmap(hDC, wnd.right—wnd.left,<br />
wnd.bottom - wnd.top);<br />
<br />
if ( hBmp )<br />
{<br />
HDC hMemDC = CreateCompatibleDC(hDC);<br />
HGDIOBJ hOld = SelectObject(hMemDC, hBmp);<br />
<br />
BitBlt(hMemDC, 0, 0, wnd.right - wnd.left, wnd.bottom - wnd.top,<br />
hDC, 0, 0, SRCCOPY);<br />
<br />
SelectObject(hMemDC, hOld);<br />
DeleteObject(hMemDC);<br />
}<br />
ReleaseDC(hWnd, hDC);<br />
<br />
return hBmp;<br />
}
Now... could I somehow keep that Memory DC, draw something in it (say, a rectangle) and then bitblt it over the original window from which I created it? And perhaps after 2 seconds I want to do it again. Could I just bitblt it from my memory DC over the original window?
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Axonn Echysttas wrote:
Now... could I somehow keep that Memory DC, draw something in it (say, a rectangle) and then bitblt it over the original window from which I created it? And perhaps after 2 seconds I want to do it again. Could I just bitblt it from my memory DC over the original window?
I'm not sure, but I think that even if you manage to do that (I guess you'd need to use IntersectClipRect before any drawing in the original DC), what you draw there would be deleted next time the window draws itself... Or is that exactly what you need?
What exactly are you trying to do?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi,
may u plz look at this error:
#include <complex>
using namespace std;
complex <double> i(0,1); // to get i=sqrt(-1) !!
complex <double> c3 = 1/i ;
The last line gives the following error:
error C2782: 'class std::complex<_Ty> __cdecl std::operator /(const _Ty &,const class std::complex<_Ty> &)' : template parameter '_Ty' is ambiguous
could be 'double'
or 'int'
error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const _Ty &)' : could not deduce template argument for 'const class std::complex<_Ty> &' f
rom 'const int'
error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const class std::complex<_Ty> &)' : could not deduce template argument for 'const class st
d::complex<_Ty> &' from 'const int'
error C2677: binary '/' : no global operator defined which takes type 'class std::complex<double>' (or there is no acceptable conversion)
Error executing cl.exe.
It also doesn't accept:
complex <double> c3 = 1 + i ;
Any help is highly appreciated!
Regards,
Eliyah
|
|
|
|
|
|
no it doesn't work either!!
Thanks
|
|
|
|
|
It looks like complex is a template class, and you have not supplied a required argument. My guess is the argument is the type used for the real and imaginary values:
complex<double> complex_with_double_components;
complex<float> complex_with_float_components; I found this[^] on the MSDN; it should help.
Software Zen: delete this;
|
|
|
|
|
How much contention an InterlockedExchangeAdd can stand on a x86 box?
I'm looking for a rough figure how many threads would have to hit the same variable repeatedly how often before I get a notable slow down. I guess this is more critical on a multi-processor-system (so I can't test that)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
The interlocked shouldn't cause much trouble. They use a CPU opcode whichs locks the bus for the time that operation needs to complete. That's normally only a few CPU clocks.
I don't think that the performance of multi-processor-systems is influenced very much by this function because windows does use this kind of functions very frequently for every kind of synchronization!
Don't try it, just do it!
|
|
|
|
|
Hi
I want to find what is the memory usage my application
eg. myapp.exe is the output of myapp.cpp.
when the exe is running it has to print current memory usages at certain execution point.
//myapp.cpp
#iclude <iostream.h>
long getMemStatus()
{
//this method has to find what is the size of memory usage in its current process space
}
void main ()
{
cout<<"\n1. current mem usage:"<
|
|
|
|
|
You are not likely to see much difference for a 'new' on a single int variable unless your application is right on the threshold of an internal allocation block.
If you program is that sensitive to memory, you will probably have more memory trouble trying to find out how much remains than not doing so, since the act of looking up the memory and tracking it will consume memory itself!
Having said that, you can use the:
1. C runtime heap walking routines - these will tell yu what C runtime library allcoations posess
2. Win32 heap walking routines - what memory allcoations your process has made
3. Process memory usage for your entire process using VirtualQuery - find out where DLL are located and which ones are loaded, executable code image memory, reserved memory, commited memory, etc.
|
|
|
|
|
thanks
Blake Miller wrote:
You are not likely to see much difference for a 'new' on a single int variable unless your application is right on the threshold of an internal allocation block
My real problem is not for finding a single int size.
it is just a concept program.
Is there any already written code or example available?
|
|
|
|
|
I am not aware of any on CodeProject that use the VirtualQuery to traverse the memory layout.
|
|
|
|