See site in english Voir le site en francais
Website skin:
home  download  forum  link  contact

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Author Topic: CMG 2.0 update Help needed  (Read 2978 times)

0 Members and 1 Guest are viewing this topic.

Offline gattico

  • Sr. Member
  • ****
  • Posts: 289
  • Country: United States us
  • Karma: 4
17 March 2015, 13:33:19
I am asking for some help on this.

Basically I am building a pop out window like the RMS to display the data from the CMG2.0.  The reason is because on different size monitors the display is gargled.

I have built the window part before but to display the numbers is where i struggle.  I am looking at the DG code for samples

Code: [Select]
CMG4 *GetCMG4(HWND hDlg)
{
// retrieve DG interface from scenario editor
OBJHANDLE hVessel;
// SendMessage(hDlg, WM_SCNEDITOR, SE_GETVESSEL, (LPARAM)&hVessel);
return (CMG4*)oapiGetVesselInterface(hVessel);
}
BOOL CALLBACK CMG4_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CMG4 *sts = (uMsg == WM_INITDIALOG ? (CMG4*)lParam : (CMG4*)oapiGetDialogContext(hWnd));
// pointer to vessel instance was passed as dialog context

switch (uMsg) {
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
oapiCloseDialog(hWnd);
return TRUE;
//case IDC_PLBAYOP:
// sts->plop->OpenDialog();
// break;
case IDC_RMSOP1:
oapiOpenDialogEx(g_Param.hDLL, IDD_DISPLAY, Damage_DlgProc, DLG_CAPTIONCLOSE, sts);
break;


}
break;
}
return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}

// ==============================================================
// Message callback function for RMS control dialog box
// ==============================================================
BOOL CALLBACK EdPg3Proc(HWND hTab, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CMG4 *CM;

switch (uMsg) {
case WM_INITDIALOG: {
CM = (CMG4*)oapiGetVesselInterface((OBJHANDLE)lParam);
CM = GetCMG4(hTab);
UpdateDamage(hTab, CM);
case WM_COMMAND:

break;
}
}
return FALSE;
}

BOOL CALLBACK Damage_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CMG4 *CM = (uMsg == WM_INITDIALOG ? (CMG4*)lParam : (CMG4*)oapiGetDialogContext(hWnd));
// pointer to vessel instance was passed as dialog context

switch (uMsg) {
case WM_INITDIALOG:
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
oapiCloseDialog(hWnd);
return TRUE;

}
break;
}
return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}

void UpdateDamage(HWND hTab, CMG4 *CM)
{
int i;
char cbuf[256];
CM->NEWHEADING = 10;
i = (int)(CM->NEWHEADING);
sprintf(cbuf, "%d %%", i);
SetWindowText(GetDlgItem(hTab, IDC_HEADING), cbuf);


}

I get the display but the value doesn't change.  I think I need to go to UpdateDamage.  But I get :
Error 3 error C3861: 'UpdateDamage': identifier not found C:\orbiter100830\Orbitersdk\samples\NEWCMG\CMG4.CP P 172 1 NEWCMG

Even though it is present there.  Hope to get some idea/help
Thanks

« Last Edit: 18 March 2015, 13:19:56 by gattico »

Offline Cras

  • Full Member
  • ***
  • Posts: 101
  • Country: United States us
  • Karma: 3
Reply #1 - 09 August 2015, 23:33:52
A pop out window would be great.   I know the pain you are going through, when I tried to code some dialogue boxes for an XR-2 light add-on I was making, the calls for these kinds of functions are not C++ but C, and I asked around and a good friend of mine couldnt even get it to work properly.

That same guy did code the HUD drawer though, maybe that could be a temporary solution to the problem while you look to figure this way out.   The HUD drawer is what Launch MFD and RV Orientation uses to display all its information on the screen.

Orbiter | SSMS2007 | FSX

Offline Bibi Uncle

  • Legend
  • ******
  • Posts: 2260
  • Country: Canada ca
  • Karma: 15
    • Site web perso
Reply #2 - 10 August 2015, 05:30:04
You need to declare your UpdateDamage method before calling it in EdPg3Proc. The declaration should look like this :

void UpdateDamage(HWND hTab, CMG4 *CM);

(Don't forget the semi-colon)

You should put it at the very beginning of your file, or inside a CMG4.h header file if you have one (I don't think it's the case, since you do not include it...)

Edit:
You should add a break after your call to UpdateDamage. Currently, it's not mandatory, but if you add code inside the WM_COMMAND case, it will be a nightmare to debug.

Bibi Uncle
"Can't keep my eyes from the circling sky
Tongue-tied and twisted just an earth-bound misfit"

- Learning to Fly, Pink Floyd

Mireille :love:

Offline gattico

  • Sr. Member
  • ****
  • Posts: 289
  • Country: United States us
  • Karma: 4
Reply #3 - 11 August 2015, 01:12:24
Thanks.  I put the :
void UpdateDamage(CMG4 *CM, HWND hWnd)
{
   if (!hWnd) hWnd = oapiFindDialog(g_Param.hDLL, IDD_DISPLAY);
   if (!hWnd) return;
   CM->NEWHEADING = 10;
   char cbuf[16];
   sprintf(cbuf, "%0.0f %%", CM->NEWHEADING);
   SetWindowText(GetDlgItem(hWnd, IDC_HEADING), cbuf);


}

before the call back.

But I get a 0 rather than a 10


Offline Bibi Uncle

  • Legend
  • ******
  • Posts: 2260
  • Country: Canada ca
  • Karma: 15
    • Site web perso
Reply #4 - 11 August 2015, 04:00:31
I don't know why you have this error. The assignation is correct, your sprintf formating is correct, the cbuf is correct. Perhaps your if(!hWnd) return; is called and the update is not made. Or, your GetDlgItem fails and returns nothing.

Can you check in the debugger (or by printing it in oapiDebugString) that cbuf does contain 10 ? If it's the case, your SetWindowText is probably the problem.

Bibi Uncle
"Can't keep my eyes from the circling sky
Tongue-tied and twisted just an earth-bound misfit"

- Learning to Fly, Pink Floyd

Mireille :love:

Offline gattico

  • Sr. Member
  • ****
  • Posts: 289
  • Country: United States us
  • Karma: 4
Reply #5 - 11 August 2015, 14:53:34
Thanks.  How do I print it using the oapiDebugString?

I am having a hard time getting the debugger to run I get an error about relative path,....


Offline Bibi Uncle

  • Legend
  • ******
  • Posts: 2260
  • Country: Canada ca
  • Karma: 15
    • Site web perso
Reply #6 - 12 August 2015, 22:52:49
In order to write to the oapiDebugString, use this:

Code: [Select]
sprintf(oapiDebugString(), "%s", cbuf);
To use Visual Studio debugger, you need to specify the absolute path to orbiter.exe and the absolute path to the Orbiter directory. That's all it needs.

Bibi Uncle
"Can't keep my eyes from the circling sky
Tongue-tied and twisted just an earth-bound misfit"

- Learning to Fly, Pink Floyd

Mireille :love:

Offline gattico

  • Sr. Member
  • ****
  • Posts: 289
  • Country: United States us
  • Karma: 4
Reply #7 - 13 August 2015, 00:11:50
Thanks.
I have this no ctd but no data s shown:
Code: [Select]
void UpdateDamage(HWND hTab, CMG4 *CM)
{
int i;
char cbuf[256];
CM->NEWHEADING = 10;
i = (int)(CM->NEWHEADING);
sprintf(cbuf, "%d %%", i);
SetWindowText(GetDlgItem(hTab, IDC_HEADING), cbuf);
sprintf(oapiDebugString(), "%s", cbuf);

}
CMG4 *GetCMG4(HWND hDlg)
{
// retrieve DG interface from scenario editor
OBJHANDLE hVessel;
// SendMessage(hDlg, WM_SCNEDITOR, SE_GETVESSEL, (LPARAM)&hVessel);
return (CMG4*)oapiGetVesselInterface(hVessel);
}
BOOL CALLBACK CMG4_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CMG4 *sts = (uMsg == WM_INITDIALOG ? (CMG4*)lParam : (CMG4*)oapiGetDialogContext(hWnd));
// pointer to vessel instance was passed as dialog context

switch (uMsg) {
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
oapiCloseDialog(hWnd);
return TRUE;
//case IDC_PLBAYOP:
// sts->plop->OpenDialog();
// break;
case IDC_RMSOP1:
oapiOpenDialogEx(g_Param.hDLL, IDD_DISPLAY, Damage_DlgProc, DLG_CAPTIONCLOSE, sts);
break;


}
break;
}
return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}

// ==============================================================
// Message callback function for RMS control dialog box
// ==============================================================
BOOL CALLBACK EdPg3Proc(HWND hTab, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CMG4 *CM;

switch (uMsg) {
case WM_INITDIALOG: {
CM = (CMG4*)oapiGetVesselInterface((OBJHANDLE)lParam);
CM = GetCMG4(hTab);
UpdateDamage(hTab, CM);

case WM_COMMAND:

break;
}
}
return FALSE;
}

BOOL CALLBACK Damage_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CMG4 *CM = (uMsg == WM_INITDIALOG ? (CMG4*)lParam : (CMG4*)oapiGetDialogContext(hWnd));
// pointer to vessel instance was passed as dialog context

switch (uMsg) {
case WM_INITDIALOG:
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
oapiCloseDialog(hWnd);
return TRUE;

}
break;
}
return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}

https://dl-web.dropbox.com/get/debug.jpg?_subject_uid=71242599&w=AAAU2p8zjjo7-enflKQne9qmrcgloSjdW4NgiFnXH9Xrnw
This is what I have set in the debug.  I get a break.


Offline Bibi Uncle

  • Legend
  • ******
  • Posts: 2260
  • Country: Canada ca
  • Karma: 15
    • Site web perso
Reply #8 - 14 August 2015, 01:21:28
I can't see the image, I get a 403 (access forbidden).

Bibi Uncle
"Can't keep my eyes from the circling sky
Tongue-tied and twisted just an earth-bound misfit"

- Learning to Fly, Pink Floyd

Mireille :love:

Offline gattico

  • Sr. Member
  • ****
  • Posts: 289
  • Country: United States us
  • Karma: 4
Reply #9 - 14 August 2015, 01:28:04
try this:
https://dl.dropboxusercontent.com/u/71242599/debug.jpg

Ok I redid the code to get the info to put it on the screen.

  This opens the first window

Code: [Select]
BOOL CALLBACK CMG4_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CMG4 *sts = (uMsg == WM_INITDIALOG ? (CMG4*)lParam : (CMG4*)oapiGetDialogContext(hWnd));
// pointer to vessel instance was passed as dialog context

switch (uMsg) {
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
oapiCloseDialog(hWnd);
return TRUE;
//case IDC_PLBAYOP:
// sts->plop->OpenDialog();
// break;
case IDC_RMSOP1:
oapiOpenDialogEx(g_Param.hDLL, IDD_DISPLAY, Damage_DlgProc, DLG_CAPTIONCLOSE, sts);
break;


}
break;
}
return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}

I got it to show 10   :)

but the big question is how to get these to show in the window



   //DISPLAY TARGETS CAPTIONS
   skp->SetTextColor(0x00ffff);
   char cTgtP[] = { "Target pitch:" };
   skp->Text(20, 400, cTgtP, strlen(cTgtP));

   char cTgtY[] = { "Target yaw:" };
   skp->Text(20, 420, cTgtY, strlen(cTgtY));

   char cTgtR[] = { "Target roll:" };
   skp->Text(20, 440, cTgtR, strlen(cTgtR));


   //DISPLAY TARGETS VALUES
   skp->SetTextColor(0xffffff);
   char buf[4];
   sprintf(buf, "%.1lf", TargetAttitude.x);
   skp->Text(150, 400, buf, strlen(buf));

   sprintf(buf, "%.1lf", TargetAttitude.y);
   skp->Text(150, 420, buf, strlen(buf));

   sprintf(buf, "%.1lf", TargetAttitude.z);
   skp->Text(150, 440, buf, strlen(buf));

« Last Edit: 14 August 2015, 13:32:54 by gattico »

Offline Qhhfdbn

  • Newbie
  • *
  • Posts: 2
  • Karma: 1
Reply #10 - 20 November 2015, 09:33:38
Vraiment trop fort.www.coquegsm.com


« Last Edit: 26 November 2015, 08:53:11 by Qhhfdbn »