LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Native windows control

I want to make a popup window with a native window control (DateTimePicker). First I have made new panel

panelHndlMsrStart = NewPanel (0, "Measure",0 , 0, 110, 200);

Then I’ve put command button

okButtonCtrlID = NewCtrl (panelHndlMsrStart, CTRL_SQUARE_COMMAND_BUTTON_LS, "OK", 80, 70);

and DateTimePicker

hwndDTPicker = CreateDatePick(panelHndlMsrStart, 47, 120);

using following function

 

HWND WINAPI CreateDatePick (int parentPanelHndl, int ctrlTop, int ctrlLeft)

{

  HWND hwndDP=NULL;

  int hwndDlg;

  INITCOMMONCONTROLSEX icex;

  HINSTANCE hProgInst;

 

  icex.dwSize = sizeof(icex);

  icex.dwICC = ICC_DATE_CLASSES;

 

  InitCommonControlsEx(&icex);

 

  GetPanelAttribute (parentPanelHndl, ATTR_SYSTEM_WINDOW_HANDLE, &hwndDlg);

  hProgInst = GetModuleHandle (NULL);

 

  hwndDP = CreateWindowEx (0, DATETIMEPICK_CLASS, TEXT("DateTime"),

                           WS_BORDER|WS_CHILD|WS_VISIBLE|DTS_TIMEFORMAT, ctrlLeft, ctrlTop,

                           72, 23, (HWND)hwndDlg, NULL, hProgInst, NULL);

 

  return (hwndDP);

}

 

I’ve activated and displayed the panel as a modal dialog box

InstallPopup (panelHndlMsrStart);

And in the infinite loop I checked if a user pressed the OK button. If yes, program left out the loop.

 

done = FALSE;

while (done == FALSE)

{

  GetUserEvent (0, &eventPanel, &eventCtrlId);

  if (eventCtrlId == okButtonCtrlID)

    done = TRUE;

}

 

Then I destroyed the picker

DestroyWindow (hwndDTPicker);

the OK button and panel.

DiscardCtrl (panelHndlMsrStart, okButtonCtrlID);

RemovePopup (panelHndlMsrStart);


Unfortunately the DateTimePicker is not shown on the panel. But when I exchange InstalPopup for DisplayPanel and RemovePopup for DiscardPanel it works. Where is the problemle? Why I can’t put the windows control on the popup panel?

 

Mirek

Message Edited by Mirek on 02-19-2009 10:11 AM
0 Kudos
Message 1 of 8
(4,288 Views)
Message Edited by Mirek on 02-19-2009 10:13 AM
0 Kudos
Message 2 of 8
(4,286 Views)

Hello Mirek,

 

The reason you don't see the control when you display the panel as a popup is because the InstallPopup function must replace the original hwnd of the panel with a different one. The original window is destroyed, taking the Windows control window down with it.

 

This might work if you wait until after you've called InstallPopup before  calling your CreateDatePick function.

 

The reason I say "might" is because, technically speaking, CVI doesn't really support placing Windows controls directly on its UI panels. You might be able to get it to work, but there are several situations (such as the one you found, with modal panels) that are liable to cause it to no longer work. If you need to put non-CVI controls on a CVI panel, the supported mechanism for doing this is to use ActiveX controls only (assuming that the controls you need are also available as ActiveX controls).

 

Luis

0 Kudos
Message 3 of 8
(4,274 Views)

Thank you for the fast reply. I have changed the order of calling CreateDatePick and InstalPopup functions (first I call InstalPopup and then CreateDatePick) and it works. Thanks.

Maybe there is a control in LabWindows which I can use to get the time entered by the user? I’m thinking about the control which will check the proper format of entered data.

Message Edited by Mirek on 02-19-2009 11:29 AM
0 Kudos
Message 4 of 8
(4,269 Views)

Unfortunately there isn't a date/time picker control in CVI. The only place I can think of where you can enter a time in CVI is for the graph axis offset in the User Interface Editor, but that uses a custom dialog with several controls, not a time-specific control.

 

Luis

0 Kudos
Message 5 of 8
(4,246 Views)

Hello Mirek,

 

In case you were interested, there is a Microsoft ActiveX date time picker control that you can use.  The file you will need, if you don't already have it, is mscomct2.ocx (if you need to download it, you will need to register it with your OS). You can then add this control by going to the Create»ActiveX... menu item and selecting the Microsoft Date and Time Picker Control. Once you've configured the control to your specifications, right click on it and select Generate ActiveX Control Driver.  Once you've done this, you will be able to interact with the control using the CVI ActiveX functions, and the functions provided by the library you just built.

 

VARIANT vtime;
DATE date;

DTP_IDTPickerGet_Value(hTimeP, NULL, &vtime);
if (CA_VariantHasDate(&vtime) > 0)
    CA_VariantGetDate(&vtime, &date);


Here's a quick screenshot of the control. Let me know if you have any questions.

 

Date Time Picker 

 

NickB
National Instruments

Message Edited by nickb on 02-19-2009 09:49 PM
0 Kudos
Message 6 of 8
(4,237 Views)

Thank you very much for the next solution. I have tested both and I have gotten two deferent views of month calendar. On the screenshot I have presented the month calendar put on the panel as an Active X element (on the left side) and the second one put by the Win32 functions from SDK (on the right side).

 

The month calendar on the left (Active X) has the English inscription "today" at the bottom but the calendar on the right (Win32 SDK) has the Polish inscription which means “today”. I prefer the Polish one but I would like to use the Active X solution. Is there some one who has any idea why the Active X solution of putting Windows common controls on the panel in LabWindows program in Polish version of Windows OS use the English text?

 

Best regards,

Mirek 

Message Edited by MirKoz on 02-23-2009 02:30 AM
Message Edited by MirKoz on 02-23-2009 02:33 AM
0 Kudos
Message 7 of 8
(4,181 Views)

The original download link is dead, but I found the new one. Unfortunately, Windows 10 is not a supported platform:

 

"Supported Operating System

Windows 2000, Windows 2000 Advanced Server, Windows 2000 Professional Edition , Windows 2000 Server, Windows 98, Windows 98 Second Edition, Windows ME, Windows NT, Windows Server 2003, Windows XP, Windows XP Home Edition , Windows XP Media Center Edition, Windows XP Professional Edition, Windows XP Tablet PC Edition"

 

Is the inclusion of Active X in the Tools menu just a legacy item, or is there a supported way to use them on modern Windows?

0 Kudos
Message 8 of 8
(2,401 Views)