|
hi
I need to get the date as follows
Desired output eg:current date and time : 4/18/06 2:25:02PM
I used the following code but i want to know whether it's AM or PM and also i want the time in 12:00 format not 24:00hrs.
COleDateTime dtCurrentDate ;
dtCurrentDate = COleDateTime::GetCurrentTime() ;
strDate.Format(_T("%d/%d/%d\t"),dtCurrentDate.GetMonth(),dtCurrentDate.GetDay(),dtCurrentDate.GetYear()) ;
strTime.Format(_T(" %d:%d:%d"),dtCurrentDate.GetHour(),dtCurrentDate.GetMinute(),dtCurrentDate.GetSecond()) ;
strDesc += _T("current date and time")+ strDate + strTime;
thanx in advance
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
-- modified at 10:54 Friday 21st April, 2006
|
|
|
|
|
Try using the COleDateTime::Format(...) method. It allows formatting of date/time information a'la strftime(...)/_tcsftime(...) . If you want to avoid CString , you can get the underlying time value into a tm structure and pass it with your own buffer to strftime(...)/_tcsftime(...) .
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Use COleDateTime::Format for this purpose.
It returns a CString built up with the format specifiers given as argument.
E.g. Format( "%I:%M:%S %p" ), this gives a time string such as "4:51:14 PM".
Hope this helps
--
Roger
It's suppose to be hard, otherwise anybody could do it!
-- modified at 10:56 Friday 21st April, 2006
Changed to a capital 'S' in the format string
|
|
|
|
|
Hi!
I have a listview control ("SysListView32" window class) in my application.
The content of this listview is changing frequently (say 1 (insert or delete) item/sec).
It is created with (LVS_NOCOLUMNHEADER | LVS_REPORT | LVS_SORTASCENDING | LVS_SINGLESEL | LVS_OWNERDRAWFIXED) style flags.
If we see the last items of the listview (the scrollbar is on the bottom) and the inserted (or deleted) item's position is on the beginning of the list, the whole content of the listview is scrolled up / down (because the scrollbar position is not changing).
I thing this is very annoying for the users (and for me), and I decided to "fix" the position of the scrollbar by using the LVM_ENSUREVISIBLE and WM_SETREDRAW messages like this:
1, send WM_SETREDRAW (FALSE)
2, send LVM_INSERTITEM or LVM_DELETEITEM
3, adjust the scrollbar position by sending LVM_ENSUREVISIBLE
4, send WM_SETREDRAW (TRUE)
It works fine with LVM_DELETEITEM.
But LVM_INSERITEM scrolls the content (it is visible!) even if there is the "setredraw(false)" call before sending LVM_INSERITEM message!
Has anybody ever faced this problem or maybe I did something wrong?
Thanks,
mate
(I already posted this to another forum but i had no answer)
|
|
|
|
|
I have a program that disables the wireless NIC when a hard-wired network connection is detected. It works fine but there is one catch - when you want to use wireless later, you have to go to the Network Connections window and click Disable, then Enable to get it working again. People at our company just cannot remember to do this and I would really like to avoid them having to do this if possible.
The method of disabling the NIC I have used is roughly:
myMIBIFROW.dwAdminStatus = MIB_IF_ADMIN_STATUS_DOWN;<br />
dwError = SetIfEntry(&myMIBIFROW);
It works but one drawback is that the control panel Network Connections window still thinks it is enabled after this. I think this is why you have to click Disable first then Enable to get the wireless going again.
So, does anyone know how to programatically simulate a click on the Disable and Enable menu options? Any other tricks to help?
BTW - setting the status to up and calling SetIfEntry() did not work.
Thanks.
Dave
|
|
|
|
|
Sir,
I want to get some information of a cell (index of image, text etc)from a CListctrl(Report view) by giving the selected row index and column index.
Thanks in advance
Sandeep A.C
Sanc
|
|
|
|
|
use GetItem()
TCHAR tcText[MAX_PATH];
LVITEM litem;
litem.mask = LVIF_IMAGE|LVIF_TEXT;
litem.pszText = tcText;
litem.cchTextMax = MAX_PATH;
GetItem( &lviItem );
|
|
|
|
|
Might help to specify the iItem and iSubItem values as well...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
HI,
How do we get the database into the comboboxes of domodal dialog boxes(Multiple dialog boxes).I've got it into the main dialogbox.
pls let me know
swapna_signsin
|
|
|
|
|
pass the database to dialog.
i often do in this way, create a function:
int MyDialog::MoModal(MyDatabase*pDB)
{
//p_DB is class member variable: MyDatabase*p_DB;
p_DB=pDB;
return CDialog::DoModal();
}
then you can use p_DB in any way as you like.
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
i tell u, there is no such thing.
the dialog is "domodal" in same thread whatever how to call it.
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
Hi
Does anyone knows if it possible to open a .txt file in main() with the usual
ifstream in1("input.txt", ios::in) written in the main() body, and then pass to a certain function or class member function a pointer pointing to the first character of the file, without having to open the "input" file from this function. If this is not possible, how can I ask the function through some argument to open itself the file? (the function should open the file even is his name is not "input", the name could maybe be given as argument?...)
Thanks
|
|
|
|
|
Do like this. Open the file using following code,
ifstream fin;<br />
fin.open("input.txt", ios::in);
now pass this fin to your function.
You should declare your function lile this,
your_function(ifstream &in, ...);
The in will contain address of fin. So you can perform file I/O operations using in
In case of any proble, let us know.
Good luck
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Dear All,
How can I change views of CView type to CScrollViews?
This I dont want at runtime but at designtime.
What changes have to be made?
Do I have to change other OnDraw alogirthms too? since Here I would have to take consideration of available view window rect.
Best regards,
pathak
|
|
|
|
|
pathakr wrote: How can I change views of CView type to CScrollViews?
Modify the view's .h and .cpp files.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
very easy.
1)create a new project with CScrollView as view.
2)change CView to CScrollView for old project
3)compare 2 projects to see what default functions etc you should add to old project.
anyway, backup old project first
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
Hi,
I have lines places. I want to identify lines by clicking on them.
Many onLButtonDown I can scan the array of all the lines and see
whose vertex is nearer and get the line.but this may not be correct always.
How about mouse sticking in between the two vertexes, suppose I want to move the line.
Thanks
Leya
|
|
|
|
|
And what is the question exaclty ?
yang__lee wrote: but this may not be correct always.
Why ? What is the problem ? You pick the line that is closest to the point where you clicked. You can still have a maximum distance (if none of the lines is closer than a certain distance, you don't pick any of them).
yang__lee wrote: How about mouse sticking in between the two vertexes, suppose I want to move the line.
I don't understand... If the point is precisely between two line, pick one at random (it is stupid for the user to click at a point like that also )
|
|
|
|
|
Cendric,
I want dynamic effect
myline (with vertexes 1, 2, 3 which are stored in the array in the document)
1------b-------2-------------------3
\
\
\
\_\
1------b1-------2-------------------3
Now user identifies line at point b, (remember point b is between 1 and 2 and was not stored in the array. so effect should be like.. whole line moves along with mouse (rubberband effect is expected here and line should seem like it has stuck to mouse at point b) , now user keeps the line at point b1.
and line array gets updated with new points . Its a simple move line command.
But how to achive this graphical command through mfc is a question to me.
I hope , I am a bit clear to you this time.
Leya
-- modified at 8:32 Friday 21st April, 2006
|
|
|
|
|
You can use a boolean in your view class to specify if a line is being dragged or not. Then, you can also keep the data of the line being dragged: the line data plus the point on which the user has clicked. By point, I think the easiest to represent it is to hold a percentage position on the line.
Does that answer your question ?
|
|
|
|
|
But in the first place how to select the line object at the point , suggest me some alogirthm in detail.
Leya
|
|
|
|
|
Hi,
Mine is a graphic application.
When I go for printing, my graphic objects (lines rectangles etc) look
very small
as I have used the mapmode as MM_TEXT. So all of them look very small
on the printing page. I dont want to use MM_LOENGLISH as I could end
up makin huge changes in my application. How to sort this out. How to
have scalled print, preview.
Also white color elements are not displayed. so I am using (i hope its
correct)
void CMysplashView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
..
pDC->SetROP2(R2_BLACK );
..
}
thanks,
Lee
Leya
|
|
|
|
|
if u use MM_TEXT mode, u don't know printed size, because paper is in physical unit - such as mm, inch.
MM_TEXT (pixel) is not valid for paper.
set it as MM_LOENGLISH.
for a project needed to be printed, picture (text, image etc) on screen should be in MM_LOENGLISH aslo, otherwise, looking on screen is totally different from on paper.
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
You can use MM_ANISOTROPIC and set the scaling factor yourself. This method allows you to even setup positive x and y axis values, mimicing MM_TEXT.
onwards and upwards...
|
|
|
|
|
I am having a listctrl (Report view ) here I added some images
m_pmyImageList->Create( 30, 15,TRUE,5,2);
CBitmap bm,bm1;
bm.LoadBitmap(IDB_BITMAP_VIEW);
int i1 = m_pmyImageList->Add( &bm,RGB(0,0,0));
bm.DeleteObject();
bm.LoadBitmap(IDB_BITMAP_TURBO);
int i2 = m_pmyImageList->Add(&bm,RGB(0,0,0));
bm.DeleteObject();
and color of selected item text is
if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText,crBack;
if ( (pLVCD->nmcd.dwItemSpec ) ==iListPos-1 )
{
crText = RGB(255,255,255);// Selected Text color
crBack= RGB(0,0,127);/// Selection back color
}
and now the images are not getting selected. I want to make them transparent (matches with the color of selection)
How can I? Please help me .
Thanks in advance
Sandeep A.C
Sanc
|
|
|
|