Results 1 to 5 of 5

Thread: single instance of dialog

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    163

    single instance of dialog

    how to display non modal dialog only one time?
    I mean if it is alraady open the not to create the dialog.
    Purushottam

  2. #2
    Junior Member MikeyD's Avatar
    Join Date
    Nov 2002
    Location
    Germany
    Posts
    17
    Are You using VC?
    You just have to set Your Dlg-ptr to NULL (e.g. in the ctor) and then check, if it is valid:
    Code:
    	if (!m_pDlg)
    	{
    		m_pDlg = new Dlg1;
    		m_pDlg->Create(IDD_DIALOG1, this);
    		
    	}
    	m_pDlg->ShowWindow(SW_SHOW);
    (Don't forget to delete the ptr. in the dtor!)


    Is that what You want?

    Mikey

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    And if you're using pure API (which would be better!) here's the equivalent code:
    Code:
    HWND g_hDlg = NULL;
    
    //...
    if(!g_hDlg) {
      g_hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_YOURDIALOG), hwnd, DlgProc);
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    163
    Thank U very much
    Purushottam

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    163
    if (!m_pDlg)
    {
    m_pDlg = new Dlg1;
    m_pDlg->Create(IDD_DIALOG1, this);

    }
    m_pDlg->ShowWindow(SW_SHOW);


    if (!&m_pDlg)
    {
    m_pDlg = new Dlg1;
    m_pDlg->Create(IDD_DIALOG1, this);

    }
    m_pDlg->ShowWindow(SW_SHOW);

    Both of these codes give error in if statement.

    it works without pointer
    if (!m_pDlg)
    {
    m_pDlg.Create(IDD_DIALOG1, this);

    }
    m_pDlg.ShowWindow(SW_SHOW);

    but how to work using pointer?
    Purushottam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width