The following code may help u.. i have Created and Debugged demo for U. Assumming that ur using MFC Application CString strTime="06:45:18"; CString h,m,s; SYSTEMTIME st; GetSystemTime(&st); h=strTime.Mid(0,2); m=strTime.Mid(3,2); s=strTime.Mid(6,2); sscanf(h.GetBuffer(2),"%d",&st.wHour); sscanf(m.GetBuffer(2),"%d",&st.wMinute); sscanf(s.GetBuffer(2),"%d",&st.wSecond); CTime t(st); //h.Format("%d:%d:%d",t.GetHour(),t.GetMinute(),t.GetSecond()); //AfxMessageBox(h); best luck. Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
Laxman9
Posts
-
String to time converstion -
diff betwn child and worker thread?we can create UI(user interface) thread with the CreateThread() or AfxBeginThread ()api we have to pass the class as a parameter to this function which is derived from the CWinThread and should be able to provide RUNTIME_CLASS. CWinThread handles the Message pump. and what we normaly create the threads are worker threads (i.e passing the threadproc to AfxBeginThread() function) Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
-
Saving a BITMAPHere is the link of codeproject that may help you for saving the bitmap. http://www.codeproject.com/bitmap/drawing2bitmap.asp Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
-
what is the size of a empty class?that is the trick if class contains any variable the size of the class is the summation of bytes of member variables and if no variables then it's size is 1 byte. and as we know that minimum variable size is 1 byte and those for char variables. Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
-
what is the size of a empty class?first thing... The size of the empty class is 1 if it doesn't contains any member variables else its size is the total bytes required for the variables in that class. second thing... if the class contains atleast one virtual function then its size is 2 bytes without member variables as the object of the class contains the address of the VTABLE. for the existance of the object the class having minimum 1 byte size. Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
-
DLL crashinghere is the sample..code for DLL //header file dllexportsclass.h// #ifdef DLLEXPORTSCLASS_EXPORTS #define DLLEXPORTSCLASS_API __declspec(dllexport) #else #define DLLEXPORTSCLASS_API __declspec(dllimport) #endif / This class is exported from the DllExportsClass.dll class DLLEXPORTSCLASS_API CDllExportsClass { public: void show(); CDllExportsClass(void); // TODO: add your methods here. }; extern DLLEXPORTSCLASS_API int nDllExportsClass; DLLEXPORTSCLASS_API int fnDllExportsClass(void); //c++ file// include the above header file / This is an example of an exported variable DLLEXPORTSCLASS_API int nDllExportsClass=0; // This is an example of an exported function. DLLEXPORTSCLASS_API int fnDllExportsClass(void) { ::MessageBox(NULL,"function","",0); return 42; } // This is the constructor of a class that has been exported. CDllExportsClass::CDllExportsClass() { return; } void CDllExportsClass::show() { ::MessageBox(NULL,"Hello Dll","CDllExportsClass",0); } and include the header file into the project where u want to use the DLL. Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool: -- modified at 0:30 Monday 30th January, 2006 Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
-
DLL crashing[Message Deleted]
-
Again CListBoxyou may add ur code into initdialog function that insert the elements into the list box BOOL CTestDlg::OnInitDialog() { CDialog::OnInitDialog(); //my code for adding the data into listbox } Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
-
code in C language that can save and editthis is the code for reading the text file which will help you char temp1[80]; FILE *f; if ( ( f = fopen("c:\\Log.txt","r") )==NULL) { printf("Unable to open file"); return; } while(fgets(f,"%s",temp1)!=EOF) { printf("%s",temp1); } fclose(f); Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
-
How to get the handle of a Popup Menu for a window?you can use GetMenu api which gives u the main menu handle and then use the getsubmenu passing the menu handle. for creating the popup menu the following link help u.. http://dietmonday.com/windows/WinDoc/msdn/sdk/platforms/doc/sdk/win32/func/src/f88_14.htm Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool: -- modified at 23:34 Tuesday 24th January, 2006
-
Problem in getting strings with space.why u used fscanf..? why fgets not.. fscanf returns when white space is encountered. so you can use fgets which reads the file line by line. :) Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
-
Get IP address of computerSee the following from which u can get the IP address of the local machine gethostname(szHostName, strlen( szHostName ) ); //returns machine name strFullName="\\\\"+szHostName; host = gethostbyname(strFullName); //returns hostent* if(host!=NULL) { ptr = (struct in_addr *) host->h_addr_list[0]; int a = ptr->S_un.S_un_b.s_b1; // Eg. 211.40.35.76 split up like this. int b = ptr->S_un.S_un_b.s_b2; // 40 int c = ptr->S_un.S_un_b.s_b3; // 35 int d = ptr->S_un.S_un_b.s_b4; // 76 strTemp.Format("%d.%d.%d.%d",a,b,c,d); AfxMessageBox("IP:="+strTemp); } Thanks and Regards Laxman :cool: FAILURE is the first step towards SUCCESS :cool: -- modified at 23:45 Friday 20th January, 2006
-
Howto: creating a dynamic menu?// The code fragment below shows how to create a new menu for the // application window using CreateMenu() and CreatePopupMenu(). // Then, the created menu will replace the current menu of the // application. The old menu will be destroyed with DestroyMenu(). // NOTE: The code fragment below is done in a CFrameWnd-derived class. // Create a new menu for the application window. VERIFY(m_NewMenu.CreateMenu()); // Create a "File" popup menu and insert this popup menu to the // new menu of the application window. The "File" menu has only // one menu item, that is, "Exit". VERIFY(m_FileMenu.CreatePopupMenu()); m_FileMenu.AppendMenu(MF_STRING, ID_APP_EXIT, (LPCTSTR)"E&xit"); m_NewMenu.AppendMenu(MF_POPUP, (UINT) m_FileMenu.m_hMenu, "&File"); // Remove and destroy the old menu. SetMenu(NULL); CMenu* old_menu = CMenu::FromHandle(m_hMenuDefault); old_menu->DestroyMenu(); // Add a new menu. SetMenu(&m_NewMenu); // Assign a default menu. m_hMenuDefault = m_NewMenu.m_hMenu; FAILURE is the first step towards SUCCESS -- modified at 0:50 Saturday 7th January, 2006
-
how to add checkmark on selecting menu itemhi, i am not able set the check mark when i select the menu item is there any setting when creating the menu templete... the following code snapet CMenu *popMenu=mnu->GetSubMenu(0); CMenu *subpop=popMenu->GetSubMenu(3); UINT state=subpop->GetMenuState(ID_TEMP_SETPRIORITY_ABOVENORMAL,MF_BYCOMMAND); if (state & MF_CHECKED) subpop->CheckMenuItem(ID_TEMP_SETPRIORITY_ABOVENORMAL, MF_UNCHECKED|MF_BYCOMMAND); else subpop->CheckMenuItem(ID_TEMP_SETPRIORITY_ABOVENORMAL, MF_CHECKED | MF_BYCOMMAND); if any idea please let me ASAP. thanks in advance. FAILURE is the first step towards SUCCESS
-
How to add the runtime shortcut keys in applicationtry the following code....:) ' Appends a shortcut key to the caption of a menu item. Public Sub AddMenuShortcut(Menu As Menu, Shortcut As String) Menu.Caption = Menu.Caption & vbTab & Shortcut End Sub This code fragment adds shortcut keys to commands on the Edit menu: Private Sub Form_Load() AddMenuShortcut mnuEditUndo, "Ctrl+Z" AddMenuShortcut mnuEditCut, "Ctrl+X" AddMenuShortcut mnuEditCopy, "Ctrl+C" AddMenuShortcut mnuEditPaste, "Ctrl+V" AddMenuShortcut mnuEditDelete, "Del" End Sub FAILURE is the first step towards SUCCESS
-
How to add the runtime shortcut keys in applicationhi, how can i add the user shortcut keys at runtime in the applicaion FAILURE is the first step towards SUCCESS
-
how can i create worker and UI thread in single applicationhi, how can i create an application which handles both worker and UI threads. in MFC. FAILURE is the first step towards SUCCESS
-
problem with buffer in fread and fwritein fread and fwrite the first parameter is "void *" so try typecasting the first parameter as following fread((void*)b,sizeof(dtype),bigVal,fp); fwrite((void*)b,sizeof(dtype),bigVal,fp); it worked when i tried past.:) FAILURE is the first step towards SUCCESS