Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to auto load from ini esp the numbers from the ini file

how to auto load from ini esp the numbers from the ini file

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ELY M
    wrote on last edited by
    #1

    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

    D D 2 Replies Last reply
    0
    • E ELY M

      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

      D Offline
      D Offline
      David Salter
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • E ELY M

        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

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        I'm seeing several calls to GetBuffer() without corresponding calls to ReleaseBuffer(). To that end, GetBuffer() is not even necessary in the context in which you are using it. That's what CString's LPCTSTR operator is for.


        "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups