How do I go about making modeless dialog boxes? Code Provided. - Sierra Chart Programming | futures io social day trading
futures io futures trading


How do I go about making modeless dialog boxes? Code Provided.
Updated: Views / Replies:378 / 8
Created: by doetrader Attachments:2

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

How do I go about making modeless dialog boxes? Code Provided.

  #1 (permalink)
Atlanta, Georgia, USA
 
 
Posts: 19 since Dec 2018
Thanks: 2 given, 0 received

How do I go about making modeless dialog boxes? Code Provided.

Following: https://www.sierrachart.com/SupportBoard.php?ThreadID=39298

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


Quoting 
DlgResource.rc

 
Code
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



Quoting 
MainStudyFile.cpp

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

SCDLLName("My Studies")

HWND g_hwndAddTarget = 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_hwndAddTarget = CreateDialogW(NULL,					 
                                    MAKEINTRESOURCE(IDD_SIMPLEINPUTMENU),										 
                                    (HWND)sc.ChartWindowHandle,									 
                                    (DLGPROC)FooBarProc);
    ShowWindow(g_hwndAddTarget, SW_SHOW);

  } 

}

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Atlanta, Georgia, USA
 
 
Posts: 19 since Dec 2018
Thanks: 2 given, 0 received


By the way, that is all the code I have. Exactly how it is structured in my files. I'm not sure if that is the proper way to structure it or not. Any guidance will be helpful at this point.

Reply With Quote
 
  #4 (permalink)
Atlanta, Georgia, USA
 
 
Posts: 19 since Dec 2018
Thanks: 2 given, 0 received

https://www.sierrachart.com/SupportBoard.php?ThreadID=39309

Any help would be appreciated.

Reply With Quote
 
  #5 (permalink)
Atlanta, Georgia, USA
 
 
Posts: 19 since Dec 2018
Thanks: 2 given, 0 received

I still need help with all of this if anyone experienced would be willing to help in any way.

Reply With Quote
 
  #6 (permalink)
russia kaliningrad
 
 
Posts: 15 since Jan 2011
Thanks: 0 given, 15 received

Hi.
Try create a thread with MessageLoop() instead of creating dialog directly.
You can pass a pointer to s_sc structure to the dialog constructor then.
Maybe it's not a best way, but works fine for me. I'm using tnis set of classes for working with GUI windows coding - Win32++. Header only wrapper around winapi functoins, very nice to remove MFC.

Reply With Quote
The following 2 users say Thank You to ludvig for this post:
 
  #7 (permalink)
Atlanta, Georgia, USA
 
 
Posts: 19 since Dec 2018
Thanks: 2 given, 0 received


ludvig View Post
Hi.
Try create a thread with MessageLoop() instead of creating dialog directly.
You can pass a pointer to s_sc structure to the dialog constructor then.
Maybe it's not a best way, but works fine for me. I'm using tnis set of classes for working with GUI windows coding - Win32++. Header only wrapper around winapi functoins, very nice to remove MFC.

Could you provide a link to the documentation/reference on MessageLoop()? Also, could you provide a small code example of what you're talking about?

Reply With Quote
 
  #8 (permalink)
russia kaliningrad
 
 
Posts: 15 since Jan 2011
Thanks: 0 given, 15 received

OK, after holidays

Reply With Quote
 
  #9 (permalink)
russia kaliningrad
 
 
Posts: 15 since Jan 2011
Thanks: 0 given, 15 received

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Main dll *cpp:

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

SCDLLName("Dialog Test")

HANDLE m_hThread = nullptr;
CMyDialog* TestDlg = nullptr;
CWinApp TheApp;

static UINT32 __stdcall TestDlgThreadProc(void * pParam)
{
	s_sc* p_sc = reinterpret_cast<s_sc*>(pParam);
	if (p_sc == nullptr)
		return 1L;

	if (TestDlg == nullptr)
	{
		TestDlg = new CMyDialog(IDD_DIALOG, p_sc);
		TestDlg->Create();
		TestDlg->ShowWindow();
		TestDlg->UpdateWindow();
		TheApp.Run();
	}

	_endthreadex(0);
	return 0;
}

void StartDialog(SCStudyInterfaceRef sc)
{
	UINT ThreadId = 0;

	if (m_hThread == nullptr)
	{
		m_hThread = (HANDLE)::_beginthreadex(NULL,
			NULL,
			TestDlgThreadProc,
			&sc,
			CREATE_SUSPENDED,
			&ThreadId);

		if (NULL == m_hThread)
		{
			return;
		}
		else
		{
			::ResumeThread(m_hThread);
			sc.IsFullRecalculation = 1;
		}
	}
}


SCSFExport scsf_DialogTest(SCStudyInterfaceRef sc)
{
	SCSubgraphRef Average = sc.Subgraph[0];
	 
	if (sc.SetDefaults)
	{
		
		sc.GraphRegion = 0;

		Average.Name = "Average";

		Average.PrimaryColor = RGB(0, 255, 0);
		Average.DrawStyle = DRAWSTYLE_LINE;
		Average.LineWidth = 2;

		sc.AutoLoop = 1;

		sc.AlertOnlyOncePerBar = true;
		sc.UpdateAlways = 1;
		
		sc.FreeDLL = 1;
		sc.AutoLoop = 1;

		return;
	}

	StartDialog(sc);
	
	int len = 30;
	sc.DataStartIndex = len - 1;

	
	sc.SimpleMovAvg(sc.Close, Average, len);

	
	if (sc.LastCallToFunction)
	{
		TestDlg->SendMessage(WM_CLOSE, 0, 0);

		DWORD result = WaitForSingleObject(m_hThread, INFINITE);

		if (result == WAIT_OBJECT_0)
		{
			CloseHandle(m_hThread);
			m_hThread = NULL;
			delete TestDlg;
			TestDlg = nullptr;
		}
	}
}
VS2017 project attached to this post.

As for MessageLoop(),
it is windows messaging prosedure, TheApp.Run() returns this one:

 
Code
MessageLoop()
	{
		// This gets any messages queued for the application, and dispatches them.
		MSG Msg;
		ZeroMemory(&Msg, sizeof(MSG));
		int status = 1;
		LONG lCount = 0;

		while (status != 0)
		{
			// While idle, perform idle processing until OnIdle returns FALSE
			// Exclude some messages to avoid calling OnIdle excessively
			while (!::PeekMessage(&Msg, 0, 0, 0, PM_NOREMOVE) &&
								(Msg.message != WM_TIMER) &&
								(Msg.message != WM_MOUSEMOVE) &&
								(Msg.message != WM_SETCURSOR) &&
								OnIdle(lCount) != FALSE  )
			{
				++lCount;
			}


			lCount = 0;

			// Now wait until we get a message
			if ((status = ::GetMessage(&Msg, NULL, 0, 0)) == -1)
				return -1;

			if (!PreTranslateMessage(Msg))
			{
				::TranslateMessage(&Msg);
				::DispatchMessage(&Msg);
			}

		}

		return LOWORD(Msg.wParam);
	}
Happy coding!

Attached Files
Register to download File Type: 7z SCDllDialogTest.7z (510.2 KB, 6 views)

Last edited by ludvig; January 2nd, 2019 at 06:18 PM.
Reply With Quote
The following user says Thank You to ludvig for this post:

Reply



futures io > > > > > How do I go about making modeless dialog boxes? Code Provided.

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Webinar: The Seven Most Effective Trading Setups w/Peter Davies @ Jigsaw

Oct 17
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Feed: How do you confirm Accuracy vs Historical tick data provided. FAUGH45568 Reviews of Brokers and Data Feeds 2 February 14th, 2013 06:04 PM
Questions about RR and scaling out, Spreadsheet provided treydog999 Psychology and Money Management 1 October 20th, 2012 02:01 PM
Government to Mandate Free Birth Control Provided under all Health Plans. forrestang Off-Topic 0 July 20th, 2011 04:16 PM
Black boxes for vehicles to be compulsory by next month kbit Off-Topic 0 May 25th, 2011 09:13 PM
coding for beginners : Text + Value-Boxes in your chart max-td NinjaTrader Programming 5 January 14th, 2010 06:56 AM


All times are GMT -4. The time now is 11:43 PM. (this page content is cached, log in for real-time version)

Copyright © 2019 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts