|
I need to know if I am understanding this properly:
If I want to display the time (in text) for a given number of seconds (dwSec) since Jan1, 1970 (in UTC), would I need to adjust the dwSec for the difference in time zones first before calling CTime::Format()?
Does this look right?:
DWORD dwSec = 1045688797; //Feb 19 21:06:37 2003 UTC (I think)
CTime tLoc((time_t)dwSec);
CString szLocal = tLoc.Format("%m/%d/%Y %H:%M:%S");
//Adjust for time zone diff before calling CTime::Format
//for UTC in text format:
dwSec += (tzinfo.timezone * 60);
//Adjust for DST:
if (tzinfo.dstflag)
dwSec -= 3600;
CTime tUTC((time_t)dwSec);
CString szUTC = tUTC.Format("%m/%d/%Y %H:%M:%S");
If there is a better way, I would appreciate any tips, but I still need to know if the above is correct.
Thank you very much.
|
|
|
|
|
I am wondering where I should put the On_WM_SIZING :
afx_msg void OnSize(UINT nType, int cx, int cy);
<code> afx_msg void OnSizing( UINT nSide, LPRECT lpRect);</code> here????
afx_msg void OnGetMinMaxInfo(MINMAXINFO* pMMI);
DECLARE_MESSAGE_MAP()
<code> afx_msg void OnSizing( UINT nSide, LPRECT lpRect);</code> or here????
Similarly:
BEGIN_MESSAGE_MAP(CResizeableFileDialogParentWnd, CDialog)
ON_WM_SIZE()
<code>ON_WM_SIZING()</code>
ON_WM_GETMINMAXINFO()
<code>ON_WM_SIZING()</code>
END_MESSAGE_MAP()
Appreciate your help,
ns
|
|
|
|
|
Anytime you edit the message maps manually, put your changes outside the //{{AFX //}}AFX section to avoid breaking ClassWizard.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks. I put them in the proper place now...
Appreciate your help,
ns
|
|
|
|
|
Hi,
I am beginning to write Windows applications and i have running into a few problems.
Environment: WinXP pro, Visual C++ 6.0 SP5
I currently have a dialog box with a few CEdit controls. When I try to debug my program using breakpoints or the run command (F5), the program breaks into assembly code as soon as I try to type anything into the CEdit controls. After a few 'steps' i get a message in the output pane: "First Time Exception: Integer Divide by Zero." I can push buttons though without any trouble. Using the execute (CTRL-F5) i can get to program to run fine, but obviously no debugging.
After a fair bit of swearing and searching it seems to happen when the program needs to write to a CEdit control.
A friend of mine has the same problem on windows 2000. I tried my program on my gf's computer running Win98SE and it works fine.
last bit of information, I tried running a demo from the book "Introduction to MFC" by deitel & deitel (not worth the money, btw) and it presents the same behaviour under WinXP and runs fine under Win98
Thanks a bunch
Marc
|
|
|
|
|
If your seeing Assembler instead of C++ it means that the C++ source code isn't available. When you install VC++ make sure you install the MFC and CRT source code. You can go back and install just the bits you want later on.
A "First Time Exception" exception is one that is caught, probably by a try - catch block. You should be able to see precisely why the divide by zero is occuring.
Don't fool yourself into thinking everything is fine just because it appears to run ok on some other machine or version of Windows.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hi:
I'm a VC++ beginner and i want to write a Custom EDIT-BOX activex that work with different language (not english) for example arabic keyboard so i need to set text-alignment to right, in the other hand i want to show Text in the control in a Right-To-Left-Reading-Order programaticaly. also i need to move cursor in edit box to left not right(by default.)
How can i do this ? is there any API for this purpose? Please Help me.
please excuse me for bad comments.
|
|
|
|
|
your project requirements are inappropriate for a "VC++ beginner"
"That's just my opinion... I could be wrong."
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
Hi
A very unexpected error happened...below is the code snippet.
CMy3027View *pView;
CMainFrame *pMF = (CMainFrame*)AfxGetMainWnd();
pView = (CMy3027View*)pMF->GetActiveView();
m_numOfValues= pView->m_imageIndex;
where m_numOfValues is declared as a class member variable(integer),
m_imageIndex is a public member variable of my CView class.
1.
On debugging,pView->m_imageIndex is working fine but m_numOfValues just doesnt get assigned. It even ran into exception error.
2.
In a previous version of the same program, the same method of assignment had work fine. I have no idea why it's not working suddenly.
3.
When i try declaring m_numOfValues locally(in the function) instead, the assignment work fine.
4.Another problem is i declared
CMy3027View *pView;
in my class's header file, under private.But after assigning it in a member function, the subsequent functions do not see the assigned value.
Anyone has any idea wat's happening?
pls help..
thks
|
|
|
|
|
In relese that assigment might be optimized, so it is not surprizing you do not see it. As for the exception the code below might show you the problem
raner wrote:
pView = (CMy3027View*)pMF->GetActiveView();
if(0 == pView)
MsgBox("This is the problem");
|
|
|
|
|
oh yah, i do get the "This is the problem" message box..but what does it mean?;P
|
|
|
|
|
it means the GetActiveView() stopped worked in your program. Check carefully what it does (if you have source control check what it used to do)
|
|
|
|
|
what is source control?...i thought it simply gets the MainFrame pointer and then the active view's pointer?
anyway...i don't understand how GetActiveView() can just stop working?
|
|
|
|
|
Downcasts are always unsafe. Are you sure that the CView* returned by GetActiveView() is a CMy3027View* ? If it's not, the program may bomb...
|
|
|
|
|
i don't know how to see that the returned pointer is a CMy3027View*..but i've only one CView-derived class so i thought it should be?
|
|
|
|
|
Try to use a dynamic_cast . If the returned value is NULL , then the pointer is not of that class.
|
|
|
|
|
How do i use dynamic_cast?...sorry,i've heard of it but i've never tried anything like that..
|
|
|
|
|
Do this:
pView = dynamic_cast<CMy3027View*>(pMF->GetActiveView());
if(pView)
m_numOfValues= pView->m_imageIndex;
You might have to turn on the RTTI option in VC.
|
|
|
|
|
It ran into exception handling error while executing
pView = dynamic_cast<cmy3027view*>(pMF->GetActiveView());
Anyway...is there a better way to obtain member variables of a CView class then?
|
|
|
|
|
good grief
the code you posted is horribly wrong considering it was provided to you correctly
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
;Poops...i mean i did run the right statement(that below) when i got an exception error.
pView = dynamic_cast<cmy3027view*>(pMF->GetActiveView());
|
|
|
|
|
oh, u missed the "display this message as-is (no HTML)" check box. sorry
did you turn on the RTTI build option?
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
i c i c
yes i did enable it, under project->settings->c++ language...
|
|
|
|
|
I want to Make an Application ( MDI one )
the APPlication support one type of document ( texte document ) for that i need to the classe of wiew must be as EditView Class , and that's not a problem !
I let to the user put his texte in the first window and when he finish , if he click for a menu item ( for emple " Draw") a new Window ( Child Window ) must be apear (created)
and this window contain some Draw ( Squars lines ... etc )
|
|
|
|
|
First of all you need to make a new class inherited from CView , then register a new document template. The document template registration is done in the CWinApp of the program, you will find a code like this in the InitInstance() of the CWinApp ;
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_MultiDocMDITYPE,
RUNTIME_CLASS(CMultiDocMDIDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CMultiDocMDIView));
AddDocTemplate(pDocTemplate);
This creates a document tempalte formed of document class CMultiDocMDIDoc and child frame class CChildFrame and view class CMultiDocMDIView . The IDR_MultiDocMDITYPE is a resource id given for a string table entry and an icon and a menu to be attached to that document template.
Anyw, let's assume you made a CView class named CDrawView , you should add similar lines to register a new document template for it, like these
m_pMyDocTemplate = new CMultiDocTemplate(IDR_SECONDTYPE,
RUNTIME_CLASS(CMultiDocMDIDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CDrawView));
AddDocTemplate(pDocTemplate);
where m_pMyDocTemplate is a public member data you should declare in the App class of type CMultiDocTemplate* .
Just add these after the preivous document template registration. If you run your project now you will be asked to choose which document template to use. The names given to them are the name you have entered in the string table entry under the given ID (for our e.g. it is IDR_SECONDTYPE , just take a look on the default type entry and see how to make this string).
Well! you are going to choose the edit view document template and write whatever you want, then we come on the part needed to start the view window. This code should do it and it should be run from the CMainFrame class:
CMDIChildWnd * pMDIActive = MDIGetActive();
ASSERT(pMDIActive!=NULL);
CDocument * pDoc = pMDIActive->GetActiveDocument();
ASSERT(pDoc != NULL);
CMDIChildWnd * pNewFrame =
(CMDIChildWnd *)theApp.m_pMyDocTemplate->CreateNewFrame(pDoc, NULL);
if(pNewFrame == NULL)
return 0;
theApp.m_pMyDocTemplate->InitialUpdateFrame(pNewFrame, pDoc);
I know it's a little complicated but it should work. Remeber to include the header of the document class in the new CDrawView class to be able to access its member data.
You may get some problems or you may get nothing, but if there is any problems I may try to send you a sample project for the whole thing.
|
|
|
|