|
Jack Handy wrote:
Like I said before, I wasn't sure how windows would handle this
No problem. That's why into a bit of detail.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Hello.
I have having trouble getting a program to restore the the location of the splitter bar in a program with splitter views (two).
Here is the code in main.
-----
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CString version = _T("1.0");
if (!m_wndSplitter.CreateStatic(this, 2, 1) ||
!m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CView2),
CSize(0, 0), pContext) ||
!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CView1),
CSize(0, MyApp.GetProfileInt(version, _T("Size"), 300)), pContext))
return FALSE;
return TRUE;
}
The progres saves the size of the window in the register. Everything looks okay and function well except for the splitter. Here is the program design.
- program first starts with default View1 at height 300 (Note: I created view2 first for UpdateAllViews() to work right similar what Prosise presents in his book).
- progres restores size of view1 via code above.
Again, I cannot see a flaw in the code unless there is a flaw somewhere in the design. I implement the same code Prosise presents in his book to return windows size and location. Here is the code that does that.
-----
if (!(reinterpret_cast<cmainframe *="">(m_pMainWnd))->RestoreWindowState())
m_pMainWnd->ShowWindow(m_nCmdShow);
-----
Is it possible that this code and the one to restore size of view1 are conflicting?
Again, I am open to all interpretations and if you have a better technique please show.
Thanks,
Kuphryn
|
|
|
|
|
I've found that I needed to make a call such as the following to get this to work.
<br />
m_SplitterWindow->SetColumnInfo(0, splitX, 0);<br />
I do this after calling CreateView(). Hope this helps!
swinefeaster
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Thanks!
Another member posted the same solution at CodeGuru. I will implement it soon. I am working on a major multithread bug right now.
Kuphryn
|
|
|
|
|
Hi.
Where should I add the functions SetColumnInfo() such that when the program starts up it will remember the size of each pane? Do I need to override a function and add SetColumnInfo()?
You including "splitx." What is that for?
Thanks,
Kuphryn
|
|
|
|
|
I'm assuming you do have the msdn help installed? Do an index search for SetColumnInfo().
splitx is the width of the slitter pane i want to start off with.
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Here is the solution in RestoreWindowState() functon.
A special thanks to members of CodeGuru and CodeProject for responding about function SetColumnInfo() and RecalcLayout().
-----
bool CMainFrame::RestoreWindowState()
{
m_bVeriReturn = false;
CString version = _T("1.0");
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(&wp);
if (((wp.flags = theApp.GetProfileInt(version, _T("flag"), -1)) != -1) &&
((wp.showCmd = theApp.GetProfileInt(version, _T("command"), -1)) != -1) &&
((wp.rcNormalPosition.bottom = theApp.GetProfileInt(version, _T("bottom"), -1)) != -1) &&
((wp.rcNormalPosition.left = theApp.GetProfileInt(version, _T("left"), -1)) != -1) &&
((wp.rcNormalPosition.right = theApp.GetProfileInt(version, _T("right"), -1)) != -1) &&
((wp.rcNormalPosition.top = theApp.GetProfileInt(version, _T("top"), -1)) != -1))
{
wp.rcNormalPosition.left = min(wp.rcNormalPosition.left,
::GetSystemMetrics(SM_CXSCREEN) - ::GetSystemMetrics(SM_CXICON));
wp.rcNormalPosition.top = min(wp.rcNormalPosition.top,
::GetSystemMetrics(SM_CYSCREEN) - ::GetSystemMetrics(SM_CYICON));
SetWindowPlacement(&wp);
m_nSplitSize = theApp.GetProfileInt(version, _T("topsplit"), 300);
m_wndSplitter.SetRowInfo(0, m_nSplitSize, 10);
m_wndSplitter.RecalcLayout();
m_bVeriReturn = true;
}
return m_bVeriReturn;
}
-----
Kuphryn
|
|
|
|
|
I have been getting access violations lately. To fix it all I have to do is delete all the object files in the Debug\ directory and recompile. After doing this everything works fine. My question is, Is this normal? Does this happen to other people too or do I have another problem that needs addressing?
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
From what you're describing your dependencies are out of whack. This is generally solved by doing a Rebuild All (or delete all binaries and Build as you did). However, you need to find out why an incremental build is not building the binaries that need to be built for the app to run. I know this isn't a complete answer, but maybe it will help you in terms of looking in a given direction.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Thanks.
Now that I know it isn't normal I will look into solving it. Just incase it proves to be a hard solution, Is there a problem besides being annoying with the method I have been using?
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
Jack Handy wrote:
Now that I know it isn't normal I will look into solving it. Just incase it proves to be a hard solution, Is there a problem besides being annoying with the method I have been using
No. It's just a pain (in terms of time) to have to rebuild all the time. However, it certainly doesn't hurt anything.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Jack this definitely isn't normal. In fact I've never seen anything like this and I work in VC++ a zillion hours a day, every day. It sounds like an out and out problem which is only randomly rearing its head, and doing a clean build makes it *appear* to go away.
Is the violation address consistent? If you are using a lesser version of Windows (not NT,2K,XP), then once something like this happens it can continue to happen until you reboot. Try and run your app under the Debugger at all times, then when you have a problem like this you can step right in and hopefully track it down. It could be a pointer which isn't pointing anywhere valid. If you have exception handling code in your app you should be picking up most if not all problems like this.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
I agree with Neville. It looks like there may be something awry in your code.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
Jack Handy wrote:
Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking.
Tom wrote:
However, you need to find out why an incremental build is not building the binaries that need to be built for the app to run.
I certainly agree with this, but in my experience VC doesn't get this wrong as long as you've got the project and it's dependencies set up correctly.
If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code.
It only happens if I do a normal build (F7) but is fine after I rebuild all.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
I don't know if this really getting anyone anywhere. Why don't you jump into the debugger and track down the exception.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Tom is right in that you're likely run into weird behavior if VC++ doesn't get the dependencies right. And a "rebuild all" forces recompilation of all modules, thereby getting around a bad dependency check.
But I suspect the real problem may lie in the code. I've often run into annoying situations (my fault) when I forget to delete an unused #define from resource.h. It causes no end of problems until I figure out that I'm calling GetDlgItem() with a bogus id. Although the ASSERT s I liberally sprinkle my code with will usually catch that. But annoying all the same.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Very good point, Ravi. That's why while it doesn't hurt anything to do rebuilds, I let him know that it's probably a dependency issue so that he can start looking in that area.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
It may be worth checking your clocks date/time and seeing if its set to earlier then some of the .cpp/.h files of your project. This can cause the project to only build partially after a change and link using old .obj files.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Any recommendations for good books on getting started with Managed C++. Preferably aimed at experienced C++ developers.
Michael
Communication is the first step towards enlightenment.
|
|
|
|
|
Hi Michael,
I personally enjoyed very much the MS Press Step By Step book. You do have to wade through a few "this is a variable" type sections. However, I personally don't mind that as I enjoy the tutorial, sequential steps approach as it quickly gets me through the demos of what I need to learn. I will add the caveat that if you've already been doing a lot of MC++, this book will be a waste for you.
I also have the APress book, but I just do not like the format of their books at all.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Hey Tom
This is slightly off-topic. But are there any 3rd party form designer tools for use with MC++?
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
I'm sure there will be and I've even had friends talk of writing one, but I haven't seen one yet.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|