|
I'd start with Pinvoke.net[^], as that contains code snippets for declaring the necessary structures and function declarations.
Once you've got those definitions in your code, the VB.NET code should follow logically form the C++ code - all I do is set the FILETIME structure to your time parts, call FileTimeToSystemTime and extract the date/time parts.
This page[^] might also help.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I've already been on Pinvoke.net and it seems that I have my structures and functions declared correctly. At the moment, using the same figures you plugged into your C code, I'm getting a year of "67137", a month of "65537" and a day of "5439544", without going into the hours, etc. Am I completely on the wrong track or are these numbers correct and just in need of some kind of further conversion to a date I an actually understand?
|
|
|
|
|
Imports System
Imports System.Runtime.InteropServices
Module Module1
<StructLayout(LayoutKind.Sequential)> _
Public Structure FILETIME
Public dwLowDateTime As UInteger
Public dwHighDateTime As UInteger
Public ReadOnly Property Value() As ULong
Get
Return CType(dwHighDateTime << 32, ULong) + dwLowDateTime
End Get
End Property
End Structure
<StructLayout(LayoutKind.Sequential)> _
Public Structure SYSTEMTIME
<MarshalAs(UnmanagedType.U2)> Public Year As Short
<MarshalAs(UnmanagedType.U2)> Public Month As Short
<MarshalAs(UnmanagedType.U2)> Public DayOfWeek As Short
<MarshalAs(UnmanagedType.U2)> Public Day As Short
<MarshalAs(UnmanagedType.U2)> Public Hour As Short
<MarshalAs(UnmanagedType.U2)> Public Minute As Short
<MarshalAs(UnmanagedType.U2)> Public Second As Short
<MarshalAs(UnmanagedType.U2)> Public Milliseconds As Short
End Structure
<DllImport( _
"kernel32.dll", _
CharSet:=CharSet.Auto, _
SetLastError:=True)> _
Public Function FileTimeToSystemTime( _
<[In]()> ByRef lpFileTime As FILETIME, _
<Out()> ByRef lpSystemTime As SYSTEMTIME) _
As Boolean
End Function
Sub Main()
Dim st As SYSTEMTIME
Dim ft As FILETIME
ft.dwLowDateTime = 2960830672
ft.dwHighDateTime = 30031143
FileTimeToSystemTime(ft, st)
System.Console.WriteLine(st.Year)
System.Console.WriteLine(st.Month)
System.Console.WriteLine(st.Day)
System.Console.WriteLine(st.Hour)
System.Console.WriteLine(st.Minute)
System.Console.WriteLine(st.Second)
End Sub
End Module
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
That is fantastic, thank you so much for taking the time. Your code worked perfectly for me and I've been able to extrapolate from that how to convert in the other direction too. I was very close to the code you've written, I'm not exactly sure where I was going wrong, but I don't care any more! Thanks again.
|
|
|
|
|
We're in the middle of a process to convert a VC6 prject to VS2008/MFC Feature Pack. So far, things have come along if not nicely, at least acceptably.
We've lifted a lot of dialogs and TabViews into customized CDockablePanes and most of it's been straightforward. We ran into trouble, though, when we had a Combo box that the user is able to enter text into occupying a grandchild. Unfortunately, some of our doc types have plenty of accelerators, many of the occupying the SHIFT-[A-Z] range. Needless to say, it's more than mildly irritating not only being unable to write "SELECT" but on top of that, a for thr moment totally irrelevant dialog pops up.
My question is:
How can I intercept accelerator translation for the select children? I understand that I sacrifice being able to do CTRL-S while mucking about with some details in a pane but that is OK.
The best solution would be to have the children/CDockablePanes use a totally different accelerator table, one that only has common accelerators like save, new, close etc. Is that at all possible?
Grey-haired regards,
Dan
|
|
|
|
|
Hey Guys,
I'm working on a simulation project that involves writing a highly accurate vehicle dynamics simulator. I'm writing the project using MFC/C++ and I'm using Visual Studio 2008. I've hit a bit of a block so I figured I would turn to the wisdom contained in this community.
1) I need to use a number of square root calculations. Would anyone happen to know a really fast square root algorithm in Visual Studio 2008 using C/C++. In my case I would be feeding it doubles.
2) I've read quite a bit about SSE Intrinsics, but apart from limited examples I haven't found a good source to say, let's do it this way or this is how you implement it. I've written the numerical engine using double varaibles, so does anyone have some tips about how do I go about converting doubles to the SSE Intrinsics.
Many Thanks
Danny
|
|
|
|
|
Have you looked at this[^] article?
|
|
|
|
|
The best answer to this is to use very strange and dangerous magic, as described here. (This is for floats, but it should be expandable to doubles easily enough.)
It's usually attributed to John Carmack, although I don't know if he came up with it, or got it from somewhere else.
PS - there's even a Wikipedia article on it!!
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
One "trick" I have resorted to in the past is to minimize if not remove the use of square roots. There are some calculations where it is unavoidable but in many there are alternatives. For example, in computing distances like for finding closest objects don't compare with the actual distance but use the distance squared because actual distance requires a square root.
|
|
|
|
|
Hi,
is you application already using MMX/SSE code? is it vectorized at all?
if not, it won't make sense to use SSE just to get a square root; you would have to get the data in and out the vector processor, which would forego all the speed gain you might achieve.
So just apply regular optimization on doubles. Some of these have already been mentioned:
- avoid SQRT; don't use it when it isn't necessary.
- use an approximation, if that is acceptable.
- for the range of numbers you're interested in, find a fast way (often a polynomial, or something smart, sometimes called "magic").
- if you need SQRT on a series of related numbers, try using each result as the initial estimate for the next.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hey Guys,
Many thanks for all your help. It has poven very useful.
All the Best
Danny
|
|
|
|
|
Hi
How to combine two bmp image files into single one ..??
Thanks
|
|
|
|
|
It depends on what you are trying to achieve. The information here[^] may help. See also any articles here on CP with regard to image manipulation.
|
|
|
|
|
Hi to all,
I am struggling a lot...Not able to find a proper example to use tabpage.
Please help me. All I need to have 2 tab page on my dialog.
-----------------------------
I am a beginner
|
|
|
|
|
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
thanks for your reply.
But I am really now snatching my hair...Not able to solve this since today morning..please help
I have a tab control in a dialog box. Now I need to have all other dialog ie property pages onto the tabcontrol. I dont want to create another property sheet then attache all pages.
Till now what I have is, the main dialog, which will create a property sheet on oninitdialog
CPropertySheet PropertySheet ("Format");
Style StylePage;
style2 StylePage2;
PropertySheet.AddPage (&StylePage);
PropertySheet.AddPage (&StylePage2);
if (PropertySheet.DoModal () == IDOK)
{
}
It appears as a different dialog.... when i close this property sheet the old/main dialog appears...I want a tabcontrol instead of proerty sheet. so that all pages appears in the main dialog itself
-----------------------------
I am a beginner
|
|
|
|
|
hrishiS wrote: Till now what I have is, the main dialog, which will create a property sheet...
No, the property sheet IS the dialog. All you need to do is change "CDialog " to "CPropertySheet " in the .h and .cpp files. Create a dialog template for each of the tabs you need (two in your case). Create a class for each of those dialog templates. Add a member variable, one for each class, to the sheet's class. Call AddPage() in the sheet's constructor. All of this is spelled out in the link I provided.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I will do the exact same.
But could you please tell me, instead of creating a property sheet. can I do it using the tabcontrol which is there in the control box?
-----------------------------
I am a beginner
|
|
|
|
|
hrishiS wrote: But could you please tell me, instead of creating a property sheet. can I do it using the tabcontrol which is there in the control box?
Presumably. I tried a few times long ago, could not get it to go, and never bothered trying again.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
In MFC, PropertySheet and PropertyPage are intertwined classes, PropertyPages can only be placed on PropertySheets and there is some expectation on the operation of the parent class. Trying to mimic this behavior with your own Dialog / TabControl and Dialogs means trying to replicate many of the functions and interactions provided by the PropertySheet / PropertyPage classes.
What you seem to want to do can be easily done with managed C# and WPF so, unless you are totally committed to C++, I'd say switch languages.
|
|
|
|
|
Chuck O'Toole wrote: In MFC, PropertySheet and PropertyPage are intertwined classes, PropertyPages can only be placed on PropertySheets and there is some expectation on the operation of the parent class.
It's fairly obvious that the two go together. I don't recall stating otherwise.
Chuck O'Toole wrote: Trying to mimic this behavior with your own Dialog / TabControl and Dialogs means trying to replicate many of the functions and interactions provided by the PropertySheet / PropertyPage classes.
Where did I mention trying to mimic/duplicate those classes?
Chuck O'Toole wrote: What you seem to want to do can be easily done with managed C# and WPF so, unless you are totally committed to C++, I'd say switch languages.
Not sure too many PMs would up and go with that suggestion.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
My reply was to the original poster, I replied as I was reading the chain.
Given the original posters problem and their difficulty with the task at hand, and their apparent "requirement" for dialogs in a tab control, I suggested a different language.
I have implemented tabs with dialogs (with tabs with dialogs, ...) and it is not easy and I'm no slouch at programming. It's also something I can't just give out as classes (they are owned by my employer and are "intellectual property" so I'm not free to give them away).
However, in other projects using C#, this was almost trivial to implement. So, some PM's have a choice between investing lots of time trying to implement something difficult (where the skill of the programmer is also a factor), changing the design to not do this (tabs with dialogs), or change languages with a higher probility of success. Their choice, all I did was make the suggestion.
As for that being posted as a reply deeper in the chain, sorry about that.
|
|
|
|
|
Originally posted as a reply to a reply when I meant it as a reply to the original poster. Hope this one's in the right place.
In MFC, PropertySheet and PropertyPage are intertwined classes, PropertyPages can only be placed on PropertySheets and there is some expectation on the operation of the parent class. Trying to mimic this behavior with your own Dialog / TabControl and Dialogs means trying to replicate many of the functions and interactions provided by the PropertySheet / PropertyPage classes.
What you seem to want to do can be easily done with managed C# and WPF so, unless you are totally committed to C++, I'd say switch languages.
|
|
|
|
|
Hello Guys,
I am new to MFC developement.
My problem is,
I am having a full screen dialog. Its hiding task bar perfectly. But when i display the custom messagebox on it ( which is again another dialog) over the full screen dialog, it causes the task bar being visible. I tried to add SHSipPreference(m_hWnd, SIP_FORCEDOWN) in constructor of custom messagebox dialog but its of no use.
I want the below dialog full screen even in case of custom message box over it.
Waiting for your quick reply.
Thanks and Regards,
Rushikesh123
|
|
|
|
|
In my application i have written code for creating process for showing new exe now when i terminated my application my application gets terminated but my pdf remains open it is not terminated anyone tell me how to terminate that process
|
|
|
|