Login Page - Create Account

Support Board


Date/Time: Tue, 25 Feb 2025 10:03:36 +0000



Post From: How to get modeless dialog box working? Code Provided.

[2018-12-21 08:00:57]
doetrader - Posts: 13
Following: How to make modeless dialog boxes for a sierra chart study? Code provided.

I am unable to get a modeless dialog box to popup when a Shortcut Menu item is pressed. Here is what I have:

DlgResource.rc


IDD_SIMPLEINPUTMENU DIALOGEX 0, 0, 215, 78
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Foobar"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDINPUTBOX,38,29,144,14,ES_AUTOHSCROLL | WS_GROUP
GROUPBOX "Bar",IDC_TARGETINROUP,25,7,169,44,BS_FLAT | WS_GROUP
DEFPUSHBUTTON "OK",IDOK,112,57,50,14
PUSHBUTTON "Cancel",IDCANCEL,51,57,50,14
END



MainStudyFile.cpp


#include "resource.h"
#include <windows.h>
#include "sierrachart.h"

SCDLLName("My Studies")

HWND g_hwndFooBar = NULL; // Window handle of dialog box

int foo;

BOOL CALLBACK FooBarProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)

{

UNREFERENCED_PARAMETER(lParam);

switch (message)

{

case WM_INITDIALOG:

return TRUE;

case WM_COMMAND:

switch (LOWORD(wParam))

{

case IDOK:

foo = GetDlgItemInt(hwndDlg, IDINPUTBOX, NULL, FALSE);

return TRUE;



case IDCANCEL:

DestroyWindow(hwndDlg);

return TRUE;

}

}

return FALSE;

}


SCSFExport scsf_FooBarStudy(SCStudyInterfaceRef sc)

{

if (sc.SetDefaults)

{



sc.GraphName = "Foo bar study";



sc.StudyDescription = "";



sc.GraphRegion = 0;



sc.AutoLoop = 0;



sc.FreeDLL = 1;



return;

}



int& r_MenuID = sc.GetPersistentInt(1);



if (sc.LastCallToFunction)

sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, r_MenuID);



if (r_MenuID <= 0)

r_MenuID = sc.AddACSChartShortcutMenuItem(sc.ChartNumber, "bar");



if (r_MenuID < 0)

sc.AddMessageToLog("Add ACS Chart Shortcut Menu Item failed", 1);



if (sc.MenuEventID != 0 && sc.MenuEventID == r_MenuID)

{

g_hwndFooBar = CreateDialogW(NULL,          
MAKEINTRESOURCE(IDD_SIMPLEINPUTMENU),                    
(HWND)sc.ChartWindowHandle,                  
(DLGPROC)FooBarProc);
ShowWindow(g_hwndFooBar, SW_SHOW);

}

}

Date Time Of Last Edit: 2018-12-24 07:13:48