|
donno does this help??
COleDateTime::SetTime( int nHour, int nMin, int nSec );
CTime::GetYear
CTime::GetMonth
CTime::GetDay
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Be careful converting these two.
They are really apples and oranges.
CTime encapsulates an interval from
some known time (placement on a time
time line whose origin is attached to
a specific event) whereas COleDateTime
merely encapsulates a time representation
such as 5JUL1998 7:23AM. (placement on a
timeline whose origin is not attached to
any specific event)
So when converting, you need to provide
the origin value by which the COleDateTime
can be interpreted.
I prefer to convert as explicitly as possible
and not use methods which implicitly specify
the origin value for the COleDateTime conversion.
(that way lies madness.)
|
|
|
|
|
Oh yeah, code:
// ASSUMES COleDateTime represents UTC times
// COleDateTime --> CTime
COleDateTime Origin(1970,1,1,0,0,0); // corresponds to time_t(0) in UTC
CTime T(time_t((U-Origin).GetTotalSeconds()));
// CTime --> COleDateTime
double SecInDay=86400.0;
COleDateTime U=Origin+COleDateTimeSpan(T.GetTime()/SecInDay);
|
|
|
|
|
Hi,
I have an application that uses the list view to show some data. I want to be able to highlight some of the lines, let's say in red background. Is there a way to change the color of a specific line in the list view?
I tried to use the selection option but as soon as I click with the mouse on one of the items, all the selections are gone,
Any help is appreciated
Thank you
Shay Harel
|
|
|
|
|
|
Great, exactly what I needed
|
|
|
|
|
Hi
I don't know exactly how to explain my question...I'll try it that way:
Say I have created my own class CFoo , it has a function called void CallApplication(???) . I have seen classes where you could use parameters like
m_myClass.CallApplication(CFoo::Notepad);
How do I need to define my function/parameters in the class in order to let the user use parameters that way? E.g. you can use CFile like that CFile file("C:\foo.txt", CFile::typeBinary | CFile::modeRead); (I know that typeBinary is only for derived classes, I just wanted to show what my question is)
hope you understand my problem
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Have a member in ur class:
static int Notepad;
or static enum { Notepad, WordPad };
and Somewhere
void CallApplication ( int openWhat )
{
switch ( openWhat )
{
case Notepad:
break;
}
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thank you very much! I didn't know I had to make those variables static
But why can I access the variables from outside the class now even if they are protected/private?
And one more question:
Actually if I type the second colon (e.g. CFoo:: ) VC usually shows me a list of all variables and functions available for this class, but my variables inside the enum do not appear in this list. Why?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Just the name of the enum appears!
Declaring a variable static makes this variable shared between all the instances of your class, and being "present" without needing an instance of your class either.
So u can see it as a plain static int i; C style, nothing more nothing less.
Anyway declaring a function static makes impossible to this function to access non static member variables.
But u need to declare a function static if its a worker thread and u wanna add it to ur class.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks for the very clear explanation
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I wrote the following code to display text and images in a CTreeCtrl item,
but only the text is shown in the item.
CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE);
...
CImageList MyImageList;
MyImageList.Create(16, 16, ILC_COLOR8, 0, 4);
...
// IDR_ICON1 is a 16*16 icon
MyImageList.Add(AfxGetApp()->LoadIcon(IDR_ICON1));
pCtrl->SetImageList(&MyImageList, TVSIL_NORMAL);
...
TVINSERTSTRUCT tvInsert;
tvInsert.hParent = NULL;
tvInsert.hInsertAfter = NULL;
tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE ;
tvInsert.item.iImage = 0; // zero index based, and I have only one picture
tvInsert.item.pszText = T("ItemText");
...
HTREEITEM hItem = pCtrl->InsertItem(&tvInsert);
Can you help me?
Tank you.
|
|
|
|
|
Image list neede to be a pointer because it will destruct itself otherwise.
|
|
|
|
|
|
You welcome, I had the same issue and I struggled with it for half a day
|
|
|
|
|
Folks,
Does anyone know who to disable the accelerator keys temporarily in a MFC application? I would like to disable the functionality of the entire menu bar when doing lengthy operation. Currently, I call the following function to disable the menu bar.
CMainFrame::EnableWindow ( FALSE );
Apparently, it works ok. The menu bar is grayed out and does not response to mouse clicks. However, when as user press "Alt", the menu bar turn ON again and start to operate. It seems like the "Alt" button enable the menu bar.
Anyway, to disable accelerator keys feature temporarily?
Thank you.
bluntagain
|
|
|
|
|
Folks,
Does anyone know who to disable the accelerator keys temporarily in a MFC application? I would like to disable the functionality of the entire menu bar when doing lengthy operation. Currently, I call the following function to disable the menu bar.
CMainFrame::EnableWindow ( FALSE );
Apparently, it works ok. The menu bar is grayed out and does not response to mouse clicks. However, when as user press "Alt", the menu bar turn ON again and start to operate. It seems like the "Alt" button enable the menu bar.
Anyway, to disable accelerator keys feature temporarily?
Thank you.
igloobear
|
|
|
|
|
is there any easy way to intercept serial port so that the data can be duplicated, with 1 copy sending out and 1 copy displaying in such an application??
thx so much
|
|
|
|
|
I fear you will need to dig into driver development to do that.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
didnt try it but u can try something similar to this:
http://www.codeproject.com/dll/apihijack.asp
or else u gotta work with the DDK!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Firstly, download and play with PORTMON, free from www.sysinternals.com. Unfortunately, they don't make their source available for this util(they do with some of them). but they desribe how it was implemented:-
The Portmon GUI is responsible for identifying serial and parallel ports. It does so by enumerating the serial ports that are configured under HKEY_LOCAL_MACHINE\Hardware\DeviceMap\SerialComm and the parallel ports defined under HKEY_LOCAL_MACHINE\Hardware\DeviceMap\Parallel Ports. These keys contain the mappings between serial and parallel port device names and the Win32-accessible names.
When you select a port to monitor, Portmon sends a request to its device driver that includes the NT name (e.g. \device\serial0) that you are interested in. The driver uses standard filtering APIs to attach its own filter device object to the target device object. First, it uses ZwCreateFile to open the target device. Then it translates the handle it receives back from ZwCreateFile to a device object pointer. After creating its own filter device object that matches the characteristics of the target, the driver calls IoAttachDeviceByPointer to establish the filter. From that point on the Portmon driver will see all requests aimed at the target device. A complete source code example of filtering is demonstrated by our Filemon file system monitor.
Portmon has built-in knowledge of all standard serial and parallel port IOCTLs, which are the primary way that applications and drivers configure and read status information from ports. The IOCTLs are defined in the DDK file \ddk\src\comm\inc\ntddser.h and \ddk\src\comm\inc\ntddpar.h, and some are documented in the DDK.
Signature space for rent. Apply by email to....
|
|
|
|
|
Second, learn writing drivers
Portmon also uses a driver to capture the data. Its the only reliable way.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
MSDN says:
BOOL CMyWnd::SomeLengthyProcess()
{
CWaitCursor wait;
MessageBox("Some result");
wait.Restore();
return TRUE;
why does MessageBox("Some result"); change the cursor? I dont want a messagebox in my app. It should change when the user presses a menu item. How would I do that if I dont put their MessageBox("Some result"); which makes the cursor change?
Thanks,
ns
|
|
|
|
|
MessageBox() sets the cursor because it is not aware of your needs. It just does what it is expected to do: give feedback to the user and allow clicking one of the buttons.
If you dont want a messagebox (I suppose you want another kind of feedback dialog) you will have to create a modeless dialog.
CMyProgressDialog dlg;
dlg.Create();
for(whatever)
dlg.UpdateStatus(currentstatus);
BTW: you dont need to call Restore() explicitly. CWaitCursor does it in the destructor. So when the variable wait goes out of scope the cursor is restored.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
I'm not getting it> heres what I want:
The user presses a menu item
The cursor changes to an hourglass
A function doing a lengthy operation is called
function returns
Now the hourglass reverts to normal.
So I dont need any type of window.
Is there something like:
void OnMenuItem()
{
hrGlass.SetCursor = 'hourglass';
LengthyOperation();
hrGlass.SetCursor = 'normal'
}
Thanks,
ns
|
|
|
|