how to auto load from ini esp the numbers from the ini file
-
well Im working on clock program... BOOL CMyDigClockDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here SYSTEMTIME CurTime; CString Time, tmp; GetLocalTime(&CurTime); bool cPM = false; if(CurTime.wHour >12) { CurTime.wHour -= 12; cPM = true; } Time.Format("%u:", CurTime.wHour); if(CurTime.wMinute <= 9) { tmp.Format("0%u:", CurTime.wMinute); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } else { tmp.Format("%u:",CurTime.wMinute); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } if(CurTime.wSecond <= 9) { tmp.Empty(); tmp.Format("0%u", CurTime.wSecond); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } else { tmp.Empty(); tmp.Format("%u",CurTime.wSecond); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } if(cPM == true) { Time.Insert(Time.GetLength()," PM"); } else { Time.Insert(Time.GetLength()," AM"); } m_clock.SetWindowText(Time); SetTimer(55,1000,NULL); char sIniFile[MAX_PATH]; GetModuleFileName( NULL, sIniFile, MAX_PATH ); strcpy( strrchr( sIniFile, '\\' ) + 1, "reminderclock.ini" ); char getname[MAX_PATH]; char gethour[MAX_PATH]; char getminutes[MAX_PATH]; char getname2[MAX_PATH]; char gethour2[MAX_PATH]; char getminutes2[MAX_PATH]; char getname3[MAX_PATH]; char gethour3[MAX_PATH]; char getminutes3[MAX_PATH]; char getname4[MAX_PATH]; char gethour4[MAX_PATH]; char getminutes4[MAX_PATH]; char getname5[MAX_PATH]; char gethour5[MAX_PATH]; char getminutes5[MAX_PATH]; char getname6[MAX_PATH]; char gethour6[MAX_PATH]; char getm
-
well Im working on clock program... BOOL CMyDigClockDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here SYSTEMTIME CurTime; CString Time, tmp; GetLocalTime(&CurTime); bool cPM = false; if(CurTime.wHour >12) { CurTime.wHour -= 12; cPM = true; } Time.Format("%u:", CurTime.wHour); if(CurTime.wMinute <= 9) { tmp.Format("0%u:", CurTime.wMinute); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } else { tmp.Format("%u:",CurTime.wMinute); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } if(CurTime.wSecond <= 9) { tmp.Empty(); tmp.Format("0%u", CurTime.wSecond); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } else { tmp.Empty(); tmp.Format("%u",CurTime.wSecond); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } if(cPM == true) { Time.Insert(Time.GetLength()," PM"); } else { Time.Insert(Time.GetLength()," AM"); } m_clock.SetWindowText(Time); SetTimer(55,1000,NULL); char sIniFile[MAX_PATH]; GetModuleFileName( NULL, sIniFile, MAX_PATH ); strcpy( strrchr( sIniFile, '\\' ) + 1, "reminderclock.ini" ); char getname[MAX_PATH]; char gethour[MAX_PATH]; char getminutes[MAX_PATH]; char getname2[MAX_PATH]; char gethour2[MAX_PATH]; char getminutes2[MAX_PATH]; char getname3[MAX_PATH]; char gethour3[MAX_PATH]; char getminutes3[MAX_PATH]; char getname4[MAX_PATH]; char gethour4[MAX_PATH]; char getminutes4[MAX_PATH]; char getname5[MAX_PATH]; char gethour5[MAX_PATH]; char getminutes5[MAX_PATH]; char getname6[MAX_PATH]; char gethour6[MAX_PATH]; char getm
The problem is that gethour is a string whereas m_hour is (presumably) an int. Instead of using GetPrivateProfileString(), you could use GetPrivateProfileInt().
store your internet favourites online - www.my-faves.co.uk
-
well Im working on clock program... BOOL CMyDigClockDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here SYSTEMTIME CurTime; CString Time, tmp; GetLocalTime(&CurTime); bool cPM = false; if(CurTime.wHour >12) { CurTime.wHour -= 12; cPM = true; } Time.Format("%u:", CurTime.wHour); if(CurTime.wMinute <= 9) { tmp.Format("0%u:", CurTime.wMinute); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } else { tmp.Format("%u:",CurTime.wMinute); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } if(CurTime.wSecond <= 9) { tmp.Empty(); tmp.Format("0%u", CurTime.wSecond); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } else { tmp.Empty(); tmp.Format("%u",CurTime.wSecond); Time.Insert(Time.GetLength(),tmp.GetBuffer(tmp.GetLength())); } if(cPM == true) { Time.Insert(Time.GetLength()," PM"); } else { Time.Insert(Time.GetLength()," AM"); } m_clock.SetWindowText(Time); SetTimer(55,1000,NULL); char sIniFile[MAX_PATH]; GetModuleFileName( NULL, sIniFile, MAX_PATH ); strcpy( strrchr( sIniFile, '\\' ) + 1, "reminderclock.ini" ); char getname[MAX_PATH]; char gethour[MAX_PATH]; char getminutes[MAX_PATH]; char getname2[MAX_PATH]; char gethour2[MAX_PATH]; char getminutes2[MAX_PATH]; char getname3[MAX_PATH]; char gethour3[MAX_PATH]; char getminutes3[MAX_PATH]; char getname4[MAX_PATH]; char gethour4[MAX_PATH]; char getminutes4[MAX_PATH]; char getname5[MAX_PATH]; char gethour5[MAX_PATH]; char getminutes5[MAX_PATH]; char getname6[MAX_PATH]; char gethour6[MAX_PATH]; char getm
I'm seeing several calls to
GetBuffer()
without corresponding calls toReleaseBuffer()
. To that end,GetBuffer()
is not even necessary in the context in which you are using it. That's whatCString
'sLPCTSTR
operator is for.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen