|
653057337 wrote: What do you think about this code’s decency now?
It has not improved yet.
You asked what it meant, you got that answered. Do you plan on doing anything yourself ?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Well, perhaps I was a bit harsh about the decency of the code. If it works, I guess nothing's wrong
with it.
653057337 wrote: ould you suggest how would you handle, if the input_time would be "Thu Jan 1 00:00:00 1970"
I guess to fit the method shown, you'd have to check for "year-wrap" and subtract a year's worth
of seconds if necessary.
I personally prefer to work with the COleDateTime class and its companion, COleDateTimeSpan.
COleDateTime handles date/time from Jan 1, 100 to Dec 31, 9999.
With COleDateTime, to find the date/time for the nearest previous Sunday at midnight,
you could
1) find the day of the week for a given COleDateTime (COleDateTime::GetDayOfWeek())
2) Calculate how many days past Sunday it is (COleDateTime::GetDayOfWeek() - 1)
3) Create a COleDateTimeSpan representing the number of days from Sunday and the
hours, mins, and seconds from midnight. (value from step 2 with COleDateTime::GetHour(),
COleDateTime::GetMinute(), and COleDateTime::GetSecond())
4) Subtract the COleDateTimeSpan from the original COleDateTime (COleDateTime::operator -=)
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you,
Also I have to think how to answer this question what would be a better implementation of this function, If the input_time represents an integer value in seconds since the epoch – and has the value 0 at precisely "Thu Jan 1 00:00:00 1970". I am totally tired to study this topic; I never studied about this and did not have an opportunity to use practically. I am having headache. I will take a little break for few hours and come back to this later.
Thank you,
Appreciate your help
Thank you
|
|
|
|
|
hi all
I should use from GIF format file for load its in to DOS
but I don't know how I use from LZW code for decode data of image and draw image in consul
plz help me
thanks alot
bye
|
|
|
|
|
Please don't cross-post.
This forum is for Managed C++/CLI.
Regular C++ questions should be posted on the Visual C++/MFC[^] board,
where you also posted this question.
Thanks for your cooperation
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all.
Here are the two classes one base and other Derived ( virtually inherited from Base)
Class Base
{
Public:
Virtual void FunB(){}
};
Class Derived: virtual public Base
{
Public:
Virtual void FunD(){}
};
When I derived class Derived virtually from Base, and when I saw the memory layout of objects of Derived in debug window; I saw two separate vfptrs; one for Base and one for Derived.
But if I do not derive class Derived virtually from Base, then there is only single vfptr in object of Derived class?
Why an extra vfptr is added/required in case of virtual inheritance?
Sameer Thakur
|
|
|
|
|
Sameer_Thakur wrote: Why an extra vfptr is added/required in case of virtual inheritance?
No, I could not see, if it is added ? Which version of VS you are using ?
P.s. Ask this question in VC++ forum, where it is suited.
Prasad
MS MVP - VC++
|
|
|
|
|
Hi, I am using Visual Studio 2005 C++/CLI. My application has a lot of functions that are used to display information on a Form. Visual Studio starts with a default form called Form1. Because my display depends on what is and is not checked in the Form1->ToolStripMenuItems I placed all of the display code in the Form1 class. What I would like to do is strip all of the display code out of the Form1 class and put it into a class of its own. I can do this but then when my display functions try to access a value in Form1 it cannot. There are no friend classes. Is there a way to allow my new Display class to access whether or not Form1->ToolStripMenuItems have been checked? I tried to pass Form1 to my Display class as an argument but I couldn't get that to work. What is the right approach to do this?
Thanks
Buck
|
|
|
|
|
I pass events.
I create delgates and events
Here is part of a help note I created for myself some time back
(May be just a bit over blown or out of date.)
-------------------------------------------------------------------------
Friday, September 08, 2006 5:04:17 PM
Problem: A form needs data back from its dialog prior to its close
One control needs to pass data to another control
[some cut]
II. A close dialog event -- the dialog closes and the form is told of the closeure
In the dialog
this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &AddColorDialog::AddColorDialog_FormClosed);
private: System::Void AddColorDialog_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e)
{
AddColorDiagCloseEvent();
}
public: delegate void AddColorDiagCloseEventHandler(void);
public: event AddColorDiagCloseEventHandler^ AddColorDiagCloseEvent;
In the form
AddColorDiag->AddColorDiagCloseEvent += gcnew WSColorTabLib::AddColorDialog::AddColorDiagCloseEventHandler(this, &WSColorTabLib::WSColorTab::AddColorDiagClosed);
void AddColorDiagClosed(void)
{
// From AddColorDiagCloseEventHandler in AddColorDialog
if (AddColorDiag)
{
delete AddColorDiag;
AddColorDiag = nullptr;
}
}
WedgeSoft
|
|
|
|
|
I have a C++/CLI Win Forms app. I am forced to provide an unmanaged
Dialog. I assume I need to write a CDialog as part of my CLR solution.
I need a little hand holding. My MFC is RUSTY! Can someone tell me
how to create a CDialog (unmanaged DLL) to be called from my WinForms
Load event.
(I have been reading, searching and trying; but no cigar. Need some help.)
WedgeSoft
|
|
|
|
|
|
It is been quite a while. I have a task to identify a calling Windows' batch script's name and its location. Basically, the batch script calls/spawns my C++ executable as a parent process and I failed to identify the parent. I can identify a number of different calling processes using NtQueryInformationProcess(), but failed to do so to the batch script. The main reason is that the batch process is shown as cmd.exe not a real script name.
Thanks a lot for the help.
|
|
|
|
|
Hi Dear,
I need to make the report view of the list control non sortable( Disable Sorting) at run time. But i could not find out any API. Can Any body help me
|
|
|
|
|
Hi!
CListCtrl sounds like MFC (i.e. unmanaged), so I guess you've asked this question in the wrong forum. Try here: Visual C++ / MFC[^]
But wait... try if this answers your question:
CListCtrl yourListCtrl;
...
CHeaderCtrl* pHeader = yourListCtrl.GetHeaderCtrl();
if(pHeader)
{
pHeader->ModifyStyle(0, HDS_BUTTONS);
pHeader->ModifyStyle(HDS_BUTTONS, 0);
}
cheers,
mykel
OMM: "Let us be thankful we have an occupation to fill. Work hard, increase production, prevent accidents and be happy."
|
|
|
|
|
Hello,
I have a few warnings in c++/ cli that I don't know how to resolve:
1)
Warning 1 warning C4835: 'startupDirectory' : the initializer for exported data will not be run until managed code is first executed in the host assembly FileUtils.cpp 76
okay in this there is a unmanaged class (#pragma managed(push,off)) with a static variable
<br />
class CFileUtils{<br />
std::wstring startupDirectory(L"");<br />
}<br />
and in the c++ file
<br />
std::wstring CFileUtils::startupDirectory(L"");<br />
2)
Warning 6 warning C4965: implicit box of integer 0; use nullptr or explicit cast AlarmViewerControl.h 594
in this case I have the following code. I have tested already all casts that I know...
<br />
DataRow ^dr = dt->NewRow();<br />
<br />
dr["clmId"] = 0;<br />
Best regards and thanks for any hint!
Hansjörg
|
|
|
|
|
First issue: If native code executes before managed code, your application may have problems with loader lock: http://msdn2.microsoft.com/en-us/library/ms172219(vs.80).aspx[^]
Second Issue: If the dr["clmId"] is an object, for example a String^ , the compiler believes you are trying to set the object to NULL with zero which is not permitted.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Okay I understand the problems, but what I can do? How I can have the warnings away (not only with pragma)?
1) I need unmanaged classes and there I have static instances...
2) I understand also this, but in this case the column is a integer...What I have to do?
Best regards
Hansjörg
|
|
|
|
|
I am only seeing small snippets of your code and don't know anything about your programming requirements. So, I can only give you general advice about what I think may be wrong.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hello,
advice 2 was really good. It works! The only thing that I don't have tested
for the first point:
I have a mixed c++/cli (for speed reasons) program. And for that I have in a few assemblies classes which are totally unmanaged:
<br />
#pragma managed(push,off)<br />
class Test<br />
{<br />
static std::wstring teststr;<br />
<br />
}<br />
In this class I don't have the possibility to use a managed string class. And the only way (that I know) to initialize the static member is
<br />
std::wstring Test::teststr = L"";<br />
Isn't it?
What do you do in that case?
Best regards
Hansjörg
|
|
|
|
|
I will try to answer your question later on after work. However, why are you writing native code in assemblies compiled by /clr? I know you said for speed reasons. However, are you aware of managed to unmanaged and unmaanaged to managed transitions (thunks) which act like speed bumps in your application. Nevertheless, if it is the only way to write the program, I understand.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thank you very much!
Yes I know about the speed bumps but I'm careful with every transition (mostly from windows forms to unmanaged code)...
Best regards
Hansjörg
|
|
|
|
|
The only way I could get native static objects to work in managed code was to place them inside of static functions or static methods. For example:
#pragma managed(push, off)
using std::wstring;
class Foo
{
public:
static const wchar_t* State(const wchar_t* value = 0)
{
static std::wstring state= L"";
if (value != 0)
state = value;
return state.c_str();
}
};
#pragma managed(pop)
using namespace System;
int main(array<System::String ^> ^args)
{
String^ str1 = gcnew String(Foo::State());
Foo::State(L"Hello!");
String^ str2 = gcnew String(Foo::State());
Console::WriteLine(str1);
Console::WriteLine(str2);
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
|
Issue #2: Have you tried manually boxing the zero?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hello!
I have this code:
(...)
static double U[5];
(...)
And, when i compile i see this error:
error C4368: cannot define 'U' as a member of managed 'bojoo::Class1': mixed types are not supported
How i fix it?
Thank´s!
Rapbs
|
|
|
|