|
Hi!
Put
long CPacket::m_counter = 1;
into cpp file, not into header.
Mukkie
|
|
|
|
|
You're telling the wrong person I sent him a demo that shows how it works.
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 works ^^
Thanks everybody. The problem I had before was that I just put the initialization below the header file, not the CPP file.
Hiya, Everybody ^^
|
|
|
|
|
Hi Friends
I have CDateTime Control to Get the Time. With the Value member variable m_VTime set the 0 in the Constructor.
Display value is 6:00:00 AM
I have a Button which only contains UpdateData(TRUE) , to get the m_VTime Variable Updated. When I press this when the time is set to less than 6:00:00 AM it gives the following error. (E.g. With in 5.am to 12.am)
Debug Assertion Filed!
Program : xxx/xxx/xx.exe
File : timecore.cpp
Line 40
Why is this coming? Please try this and give me a solution.
Regards
Gaurika
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
|
Dear Mike
This is whats in timecore.cpp in line 40. this file is a MFC File.
CTime::CTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec,
int nDST)
{
struct tm atm;
atm.tm_sec = nSec;
atm.tm_min = nMin;
atm.tm_hour = nHour;
ASSERT(nDay >= 1 && nDay <= 31);
atm.tm_mday = nDay;
ASSERT(nMonth >= 1 && nMonth <= 12);
atm.tm_mon = nMonth - 1; // tm_mon is 0 based
ASSERT(nYear >= 1900);
atm.tm_year = nYear - 1900; // tm_year is 1900 based
atm.tm_isdst = nDST;
m_time = mktime(&atm);
Line 40--->ASSERT(m_time != -1); // indicates an illegal input time
}
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
Along with Michael's suggestions always look at the output window when you get an assert. Many times, MFC will output the reason for the assert with a TRACE statement.
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.
|
|
|
|
|
Hey all.
My application (ActiveX Control) requires Rich Edit Control v3. (v2 doesn't right-align correctly from some reason).
I couldn't find a redistributable package on MS site. Can I just pick up the riched20.dll on my computer, along with 2 or 3 DLLs it depends on, and deploy them on the clients' machines (if they don't have a newer DLL)? Or is it somehow dangerous / illegal / etc.?
Thank you!
|
|
|
|
|
I can find no reference to redist of riched32.dll. So, no you can't do it.
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/default.htm?p=/msdownload/platformsdk/sdkupdate/psdkredist.htm
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Check in the Common\Redist\Redist.txt file of your VC6 install. (I can't as I'm running VS.NET). If it's listed in that file, you can redistribute it.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
What about compiling statically?
-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.
|
|
|
|
|
It's not a source code issue. The winproc for the richedit window class is in the riched20.dll file. Therefore that file needs to be present and the window class registered for you to be able to use the rich edit control.
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.
|
|
|
|
|
So compiling statically in windows doesn't compile shared libs into your binary as it does in unix? Or am I missing something?
-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.
|
|
|
|
|
Not system files. It would be a HUGE mistake. You don't want system files in your executables. Not only would it mean that you would have to build a special version for each OS, but it would also mean a special version for each SP.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
[Edited to be half-way intellible once I had a coke in me]
It wouldn't matter anyway as user applications don't link with the libraries that contain the control code (e.g., commctrl, riched, etc.) The issue is that Windows needs to load the control's encapsulating library in order to associate the window class name (passed to CreateWindow) to the window's winproc.
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.
|
|
|
|
|
I rewrote my first response to you as upon re-reading it, I found it barely intelligible. I should never write anything before my first coke.
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.
|
|
|
|
|
You're confusing a couple of different things here. There are three ways a library can be used.
- A static (or object) library is an OBJ that is linked in with your application. This file contains the actual implementation of the code. When you select the link statically with MFC, you are including the MFC static link libaries into your build.
- Like static libraries, import libraries are used by the linker to resolve function calls. However, unlike static libraries, import libraries contain no code. Instead, import libraries contain information that helps Windows load and resolve (non-static) function calls at runtime.
As an example, let's say you make a call to CreateWindow in your code. In order for this to compile, you must have that function declared somewhere. This is take care of with the inclusion of the windows.h header. Now for the application to link, you must either include an object library (static library) that contains the actual CreateWindow function or you must provide an import library that contains the information that is needed to load the DLL containing the function at runtime. For this particular function, you would always use an import library as you would never want to statically link to the system libraries. - The last way to use a library is dynamically. To do this a DLL is loaded via the LoadLibrary function and functions are resolved via calls the GetProcAddress.
Now the case of the richedit control (housed in the riched20.dll). When you use the CRichEditCtrl, you are simply using a class that wraps the RICHEDIT window class. In order for you to resolve to the CRichEditCtrl member functions you will either statically link to the MFC or dynamically link to the MFC. However, that's not all you have to do because at this point you're only making the compiler and linker happy with regards to calls to a C++ class. This has nothing to do with the underlying window.
When you create a window, you do so by calling the CreateWindow function and passing a window class. In the case of the rich edit control, this value is "RICHEDIT". When you do that, Windows will look at an internal table and see if it any code has registered a window with the name of "RICHEDI". If so, your CreateWindow succeeds (assuming the other params are corred). If not, it fails.
But how does Windows know if a Window is "registered" or not and what does that mean? If you have installed the riched20.dll, upon its loading by Windows, that DLL will call the RegisterWindow function. That function is specifically meant to associate a window class name with a winproc.
Now, if you call the CreateWindow function on a system where the riched20.dll has been installed, Windows already has loaded the DLL and the winproc function needed in order to send messages to that window (such as WM_CREATE).
Therefore, distributing the actual rich edit window code is a completely different issue than how you link with the MFC in order to use the CRichEdit class.
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.
|
|
|
|
|
Very informative, thank you.
Like I said before, I wasn't sure how windows would handle this. I was speaking from my unix experience. In unix if you are to include a library like PCRE (Perl Compatible Regular Expressions) for example, If you link normal the person running your binary has to have PCRE on their system, if you use the -static flag it compiles all the code in (resulting in a much larger binary) and you don't have to worry about your users having PCRE at all. I assumed windows would work similar.
-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:
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.
|
|
|
|
|