Login Page - Create Account

Support Board


Date/Time: Fri, 24 Jan 2025 14:50:57 +0000



[Programming Help] - [ACSIL] Put Things into Different Containers Depending on which Dialog Box Button Clicked

View Count: 1495

[2019-01-27 12:16:54]
doughtrader - Posts: 16
Using: http://win32-framework.sourceforge.net/description.htm

I'm trying to write a Sierra Chart plugin that uses a dialog box. I found some reference code (from right here: https://futures.io/sierra-chart-programming/45896-how-do-i-go-about-making-modeless-dialog-boxes-code-provided.html#post702140) that seems close to what I need (especially based on the rest of that forum thread), but I'm trying to change it to what I need. That is, a dialog box that comes when a shortcut menu item is clicked (that part is easy-peasy once I have the dialog implemented with the win32++ framework linked on the first line).

The dialog box takes text input. There are 3 buttons. An OK button, a button to click if you want the text input to go to a list called List_1, and a second button that puts the text input into a different list called List_2. At the moment, all I have is the design for this right here generated by Visual Studio:

From `NewTestDialog.rc`:

IDD_NEW_DIALOG DIALOGEX 0, 0, 215, 65
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "New SC DLL Dialog Test"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,158,37,50,14
EDITTEXT IDC_TEXT_INPUT,7,15,201,14,ES_AUTOHSCROLL
PUSHBUTTON "Buy Target",IDC_PUT_IN_CONTAINER_1,7,37,50,14
PUSHBUTTON "Sell Target",IDC_PUT_IN_CONTAINER_2,68,37,50,14
END


Now, below is parts from the code reference I have that is relevant to me and that I'm having trouble with.

From `OldTestDialog.rc`:

IDD_DIALOG DIALOGEX 0, 0, 181, 61
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Old SC DLL Dialog Test"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "ОК",IDOK,125,44,50,14
EDITTEXT IDC_EDIT1,7,7,167,14,ES_AUTOHSCROLL
PUSHBUTTON "Start Timer",IDC_BUTTON1,7,44,50,14
END

From `OldTestDialog.h`:

#pragma once
#ifndef MYDIALOG_H
#define MYDIALOG_H

class CMyDialog : public CDialog
{
public:
  CMyDialog(UINT nResID,s_sc* p_interface);
  virtual ~CMyDialog();

  void UpdateSCData();
  s_sc* m_pSCInterface;

protected:
  virtual void OnDestroy();
  virtual BOOL OnInitDialog();
  virtual INT_PTR DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  virtual void OnOK();
  virtual LRESULT SCTimer(UINT uMsg, WPARAM wParam, LPARAM lParam);

private:
  BOOL OnButtonStartTimer();
  CEdit m_Edit;
};
#endif

and from `OldTestDialog.cpp`:

#include "stdafx.h"
#include "TestDialog.h"

#define ID_SC_TIMER 110

CMyDialog::CMyDialog(UINT nResID, s_sc* p_interface) : CDialog(nResID)
,m_pSCInterface(p_interface)
{}

CMyDialog::~CMyDialog()
{
  
}

void CMyDialog::UpdateSCData()
{
  m_Edit.SetWindowTextA(std::to_string(m_pSCInterface->Subgraph[0].Data[m_pSCInterface->Index]).data());
  m_Edit.Invalidate();
}

void CMyDialog::OnDestroy()
{
  KillTimer(ID_SC_TIMER);
  ::PostQuitMessage(0);
}

INT_PTR CMyDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  UINT nID = (UINT)wParam;

  switch (uMsg)
  {
    case WM_TIMER:
    {
      switch (nID)
      {
        case ID_SC_TIMER:return SCTimer(uMsg, wParam, lParam); break;
      }
    }
    case WM_SYSCOMMAND:
    {
      switch (LOWORD(wParam))
      {
        case SC_CLOSE:
        {
          MessageBox("To Destroy this Dialog Window,\r\nyou have to remove study from chart!", "Warning!", MB_OK);
          return TRUE;
        }
      }
    }
  }
      
  return DialogProcDefault(uMsg, wParam, lParam);
}

BOOL CMyDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
  UNREFERENCED_PARAMETER(lParam);

  UINT nID = LOWORD(wParam);
  switch (nID)
  {
    case IDC_BUTTON1: return OnButtonStartTimer();
  }

  return FALSE;
}

BOOL CMyDialog::OnInitDialog()
{
  AttachItem(IDC_EDIT1, m_Edit);

  return TRUE;
}

void CMyDialog::OnOK()
{
  MessageBox("To Destroy this Dialog Window,\r\nyou have to remove study from chart!", "Warning!", MB_OK);
  return;
}


LRESULT CMyDialog::SCTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  UpdateSCData();
  return FinalWindowProc(uMsg, wParam, lParam);
}



BOOL CMyDialog::OnButtonStartTimer()
{
  SetTimer(ID_SC_TIMER, 500, 0);
  
  return TRUE;
}



How do I go about changing this implementation of CDialog so that it suits my needs better?

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account