Jose's Read Only Forum 2023

IT-Consultant: James C. Fuller => bc9Basic => Topic started by: James C. Fuller on January 11, 2017, 05:09:20 PM

Title: Dialog rc To source code utility
Post by: James C. Fuller on January 11, 2017, 05:09:20 PM
It has been an interesting few weeks. This project actually started out to be a PowerBASIC DDT to CWindow converter written in PBWin 10 using a pcre com class wrapper I wrote several years ago.
I lost interest for a couple of reasons. Bob had a VERY flexible syntax, with many items optional or ignored altogether, making the pcre rules difficult. It could have been done but I had no use for it so I bailed.
While still in the parsing mood I decided to create a utility that takes a dialog resource script and generates bc9Basic/CWindow/TCLib source. As I never do anything in moderation I added conversions for bc9Basic/TCLib, bc9Basic SDK, FreeBasic/CWindow, FreeBasic SDK, C++/TCLib (for Fred), C/C++ SDK, PowerBASIC/CWindow (PbWin10), PowerBASIC SDK (PbWin 9/10) and Oxygen Basic.
Throughout development only dialog resource scripts created with ResEd 2.2.8.0 were tested.
http://jcfuller.github.io/bc9Basic/Tools/ResEd.zip
Help File:
http://jcfuller.github.io/bc9Basic/Tools/ResEd.chm

I started with the Visual Studio 2015 Community C++ compiler but discovered I did not have a pcre static library.
NUWEN distro to the rescue. Many fine libraries included but not without a price. A huge exe of 1.5 meg was brought down to a somewhat reasonable size of 500k with UPX but there were issues. The Open File Dialog has noticeable delays so I am not using UPX. I know 64bit is listed as experimental.

Only 64bit OS Vista+ supported.

I have mixed feelings about reource dialogs versus CWindow and SDK windows.
At the beginning of the bc9Basic CWindow port (from José's FreeBasic version) I was under the impression only an sdk approach would give satisfactory display results on hi dpi monitors not set to the default setting.
I have found this is not quite true. If one adds a dpi aware section to your manifest you no longer get fuzzy text.

Also, apps using resource dialogs are smaller than their SDK counterparts.


Here is the link:

https://sourceforge.net/projects/bc9basic/files/Tools/Dlg2Src/Dlg2Src.zip/download

James

Edit:
Because of some false browser malware site protection issues I have posted ResEd and it's help file to my bc9Basic github site:
http://jcfuller.github.io/bc9Basic/Tools/ResEd.zip
http://jcfuller.github.io/bc9Basic/Tools/ResEd.chm
change above also

James

Title: Re: Dialog rc To source code utility
Post by: Patrice Terrier on January 11, 2017, 08:31:22 PM
QuoteAlso, apps using resource dialogs are smaller than their SDK counterparts.

By me, SDK always produce {much} smaller code size, than using a resource dialogs.

...
Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on January 12, 2017, 12:03:45 AM
Patrice,
  :) I doubt you have ever created a resource dialog for use with c++

Maybe comparing PB SDK to DDT but not SDK windows to a resource dialog.

See how small you can get this.
88k here with Visual Studio 2015.

//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
//                   This source created by dlg2src
//                           Target: C/C++
//------------------------------------------------------------------------------
//              link with kernel32 user32 gdi32 comctl32 libraries
//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif

#include <windows.h>
#include <commctrl.h>
#pragma comment(lib,"kernel32.lib")
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"gdi32.lib")
#pragma comment(lib,"comctl32.lib")
#include <tchar.h>
//==============================================================================
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
//==============================================================================
HFONT Create_Font (const _TCHAR* szFaceName, long lPointSize)
{
    LOGFONT  tlf = {0};
    HDC      hdc = {0};
    hdc = GetDC( HWND_DESKTOP);
    tlf.lfHeight = - MulDiv( lPointSize, GetDeviceCaps( hdc, LOGPIXELSY), 72);
    tlf.lfWidth = 0;
    tlf.lfEscapement = 0;
    tlf.lfOrientation = 0;
    tlf.lfWeight = 0;
    tlf.lfItalic = 0;
    tlf.lfUnderline = 0;
    tlf.lfStrikeOut = 0;
    tlf.lfCharSet = ANSI_CHARSET;
    tlf.lfOutPrecision = OUT_TT_PRECIS;
    tlf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
    tlf.lfQuality = DEFAULT_QUALITY;
    tlf.lfPitchAndFamily = FF_DONTCARE;
    _tcscpy(tlf.lfFaceName, szFaceName);
    ReleaseDC(HWND_DESKTOP, hdc);
    return (HFONT)CreateFontIndirect( &tlf);
}
//==============================================================================
void Center_Win (HWND hwnd)
{
    RECT     WndRect = {0};
    long     x = {0};
    long     y = {0};
    GetWindowRect(hwnd, &WndRect);
    x = ( GetSystemMetrics( SM_CXSCREEN) - ( WndRect.right - WndRect.left)) / 2;
    y = ( GetSystemMetrics( SM_CYSCREEN) - ( WndRect.bottom - WndRect.top + GetSystemMetrics( SM_CYCAPTION))) / 2;
    SetWindowPos(hwnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
//==============================================================================
void SetClientSize (HWND hwnd, long nWidth, int nHeight)
{
    RECT     rc = {0};
    RECT     rcTemp = {0};
    SetRect( &rc, 0, 0, nWidth, nHeight);
    HANDLE   hMenu = GetMenu(hwnd);
    DWORD    dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
    AdjustWindowRectEx( &rc, dwStyle, (hMenu != NULL), GetWindowLongPtr(hwnd, GWL_EXSTYLE));
    if(hMenu != NULL )
    {
        rcTemp = rc;
        rcTemp.bottom = 0x7FFF;
        SendMessage(hwnd, (UINT)WM_NCCALCSIZE, (WPARAM)0, (LPARAM)&rcTemp);
        rc.bottom +=   rcTemp.top;
    }
    if((dwStyle & WS_HSCROLL) == WS_HSCROLL )
    {
        rc.bottom = rc.bottom + GetSystemMetrics( SM_CYHSCROLL);
    }
    if((dwStyle & WS_VSCROLL) == WS_VSCROLL )
    {
        rc.right = rc.right + GetSystemMetrics( SM_CXVSCROLL);
    }
    long     cx = rc.right - rc.left;
    long     cy = rc.bottom - rc.top;
    SetWindowPos(hwnd, NULL, 0, 0, cx, cy, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
}
//==============================================================================
#define IDD_DLG1 1000
#define IDC_INDEX1 1001
#define IDC_INDEX2 1002
#define IDC_COMPANY1 1003
#define IDC_COMPANY2 1004
#define IDC_FIRST 1005
#define IDC_FIRSTNAME 1006
#define IDC_LAST 1007
#define IDC_LASTNAME 1008
#define IDC_ADDRESS1 1009
#define IDC_ADDRESS2 1010
#define IDC_CITY1 1011
#define IDC_CITY2 1012
#define IDC_COUNTY 1034
#define IDC_COUNTY2 1013
#define IDC_STATE1 1014
#define IDC_STATE2 1015
#define IDC_ZIP1 1016
#define IDC_ZIP2 1017
#define IDC_PHONE11 1018
#define IDC_PHONE12 1019
#define IDC_PHONE21 1020
#define IDC_PHONE22 1021
#define IDC_EMAIL1 1022
#define IDC_EMAIL2 1023
#define IDC_URL1 1024
#define IDC_URL2 1025
#define IDC_PRIOR 1026
#define IDC_NEXT 1027
#define IDC_FIND 1028
#define IDC_ADD 1029
#define IDC_UPDATE 1030
#define IDC_DELETE 1031
#define IDC_PRINT 1032
#define IDC_CLOSE 1033
//==============================================================================
int WINAPI _tWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR CmdLine, int CmdShow)
{
    HWND     hWin = {0};
    HWND     hCtl = {0};
    WNDCLASSEX  wcx = {0};
    MSG      uMsg = {0};
    HFONT    hFont = {0};
    _TCHAR     szClassName[] = _T("CSdkWindow");
    INITCOMMONCONTROLSEX  icc = {0};
    icc.dwSize = sizeof( icc);
    icc.dwICC = ICC_NATIVEFNTCTL_CLASS | ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_TAB_CLASSES |
                ICC_USEREX_CLASSES | ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES | ICC_ANIMATE_CLASS |
                ICC_DATE_CLASSES | ICC_HOTKEY_CLASS |   ICC_LISTVIEW_CLASSES |
                ICC_PAGESCROLLER_CLASS | ICC_PROGRESS_CLASS | ICC_TREEVIEW_CLASSES | ICC_UPDOWN_CLASS;
    InitCommonControlsEx( &icc);
    wcx.cbSize = sizeof( wcx);
    wcx.style = CS_HREDRAW | CS_VREDRAW;
    wcx.lpfnWndProc = WndProc;
    wcx.cbClsExtra = 0;
    wcx.cbWndExtra = 0;
    wcx.hInstance = hInst;
    wcx.hIcon = LoadIcon( NULL, IDI_APPLICATION);
    wcx.hCursor = LoadCursor( NULL, IDC_ARROW);
    wcx.hbrBackground = ( HBRUSH)( COLOR_BTNFACE + 1);
    wcx.lpszMenuName = 0;
    wcx.lpszClassName = szClassName;
    wcx.hIconSm = LoadIcon( NULL, IDI_APPLICATION);
    if(!RegisterClassEx( &wcx))
    {
        MessageBox (GetActiveWindow(), _T("RegisterClassEx Failed"),_T("ERROR"), MB_ICONERROR);
        return 0;
    }
    hFont = Create_Font(_T("Tahoma"),10);
    hWin = CreateWindowEx(0,szClassName,_T("Address Book"),0x10CA0800,0,0,254,245,0,(HMENU) 0,hInst,NULL);
    SetClientSize(hWin,445,490);
    hCtl = CreateWindowEx(0,_T("Static"),_T("Record No."),0x50000000,275,10,89,16,hWin,(HMENU)IDC_INDEX1,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("0  /  0"),0x50001201,361,8,70,20,hWin,(HMENU)IDC_INDEX2,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("Company"),0x50000000,9,48,105,16,hWin,(HMENU)IDC_COMPANY1,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,44,263,24,hWin,(HMENU)IDC_COMPANY2,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("First Name"),0x50000000,9,76,105,16,hWin,(HMENU)IDC_FIRST,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,72,263,24,hWin,(HMENU)IDC_FIRSTNAME,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("Last Name"),0x50000000,9,104,105,16,hWin,(HMENU)IDC_LAST,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,100,263,24,hWin,(HMENU)IDC_LASTNAME,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("Address"),0x50000000,9,132,105,16,hWin,(HMENU)IDC_ADDRESS1,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,128,263,24,hWin,(HMENU)IDC_ADDRESS2,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("City"),0x50000000,9,160,105,16,hWin,(HMENU)IDC_CITY1,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,156,263,24,hWin,(HMENU)IDC_CITY2,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("County"),0x50000000,9,188,105,16,hWin,(HMENU)IDC_COUNTY,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,184,263,24,hWin,(HMENU)IDC_COUNTY2,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("State"),0x50000000,9,216,105,16,hWin,(HMENU)IDC_STATE1,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,212,51,24,hWin,(HMENU)IDC_STATE2,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("Zip"),0x50000000,9,244,105,16,hWin,(HMENU)IDC_ZIP1,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,240,100,24,hWin,(HMENU)IDC_ZIP2,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("Phone #1"),0x50000000,9,272,105,16,hWin,(HMENU)IDC_PHONE11,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,268,121,24,hWin,(HMENU)IDC_PHONE12,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("Phone #2"),0x50000000,9,300,105,16,hWin,(HMENU)IDC_PHONE21,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,296,121,24,hWin,(HMENU)IDC_PHONE22,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("Email"),0x50000000,9,328,105,16,hWin,(HMENU)IDC_EMAIL1,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,324,263,24,hWin,(HMENU)IDC_EMAIL2,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Static"),_T("WWW"),0x50000000,9,356,105,16,hWin,(HMENU)IDC_URL1,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0x00000200,_T("Edit"),_T(""),0x50010000,119,352,263,24,hWin,(HMENU)IDC_URL2,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Button"),_T("<< Prior"),0x50010000,46,406,70,28,hWin,(HMENU)IDC_PRIOR,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Button"),_T("Next >>"),0x50010000,140,406,70,28,hWin,(HMENU)IDC_NEXT,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Button"),_T("Find"),0x50010000,235,406,70,28,hWin,(HMENU)IDC_FIND,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Button"),_T("Add"),0x50010000,331,406,70,28,hWin,(HMENU)IDC_ADD,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Button"),_T("Update"),0x50010000,46,442,70,28,hWin,(HMENU)IDC_UPDATE,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Button"),_T("Delete"),0x50010000,140,442,70,28,hWin,(HMENU)IDC_DELETE,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Button"),_T("Print"),0x50010000,235,442,70,28,hWin,(HMENU)IDC_PRINT,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    hCtl = CreateWindowEx(0,_T("Button"),_T("Close"),0x50010000,331,442,70,28,hWin,(HMENU)IDC_CLOSE,hInst,NULL);
    SendMessage(hCtl,(UINT)WM_SETFONT,(WPARAM)hFont,(LPARAM)0);
    Center_Win(hWin);
    ShowWindow(hWin, SW_SHOW);
    while(GetMessage( &uMsg, NULL, 0, 0))
    {
        if(IsDialogMessage(hWin, &uMsg))
        {
            continue;
        }
        TranslateMessage( &uMsg);
        DispatchMessage( &uMsg);
    }
    DeleteObject((HFONT)hFont);
    return uMsg.wParam;
}
//==============================================================================
LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM  wParam, LPARAM  lParam)
{
    switch(Msg)
    {
    case WM_COMMAND:
        if(LOWORD(wParam) == IDCANCEL && HIWORD(wParam) == BN_CLICKED )
        {
            SendMessage(hWnd, (UINT)WM_CLOSE, (WPARAM)0, (LPARAM)0);
        }
        return 0;
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hWnd, Msg, wParam, lParam);
}




8k with a resource dialog using Fred's TCLib.


$NOMAIN
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "TCLIB.BAT $FILE$"   
$HEADER
    #pragma comment(lib,"gdi32.lib")       
$HEADER

CONST IDD_DLG1 = 1000
CONST IDC_INDEX1 = 1001
CONST IDC_INDEX2 = 1002
CONST IDC_COMPANY1 = 1003
CONST IDC_COMPANY2 = 1004
CONST IDC_FIRST = 1005
CONST IDC_FIRSTNAME = 1006
CONST IDC_LAST = 1007
CONST IDC_LASTNAME = 1008
CONST IDC_ADDRESS1 = 1009
CONST IDC_ADDRESS2 = 1010
CONST IDC_CITY1 = 1011
CONST IDC_CITY2 = 1012
CONST IDC_COUNTY2 = 1013
CONST IDC_STATE1 = 1014
CONST IDC_STATE2 = 1015
CONST IDC_ZIP1 = 1016
CONST IDC_ZIP2 = 1017
CONST IDC_PHONE11 = 1018
CONST IDC_PHONE12 = 1019
CONST IDC_PHONE21 = 1020
CONST IDC_PHONE22 = 1021
CONST IDC_EMAIL1 = 1022
CONST IDC_EMAIL2 = 1023
CONST IDC_URL1 = 1024
CONST IDC_URL2 = 1025
CONST IDC_PRIOR = 1026
CONST IDC_NEXT = 1027
CONST IDC_FIND = 1028
CONST IDC_ADD = 1029
CONST IDC_UPDATE = 1030
CONST IDC_DELETE = 1031
CONST IDC_PRINT = 1032
CONST IDC_CLOSE = 1033


'==============================================================================
Function WinMain()
    Dim As int RetVal
    RetVal = DialogBoxParam(hInst,MAKEINTRESOURCE(IDD_DLG1),0,(DLGPROC)DlgProc,0)
    If  RetVal = -1 Then
        MsgBox("BAD")
        Function = EXIT_FAILURE
    EndIf

    Function = EXIT_SUCCESS
End Function
'==============================================================================
DlgCallBack DlgProc()
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDCANCEL
                    EndDialog(CBHNDL,0)
            End Select
    End Select
End Function
'==============================================================================



James
Title: Re: Dialog rc To source code utility
Post by: Patrice Terrier on January 12, 2017, 08:51:56 AM
My remark was based on a Theme aware Media Foundation example written by Microsoft from the latest SDK, that is using the VS resource editor.
The binary code size is 162 Kb.
Once translated to SDK it goes down to 122 Kb.
The name of the code source is MFplayer.sln, and it can be found in the SDK\samples\multimedia\mediafoundation\MFPLayer2

I must say that there are also a couple of small bitmaps embedded altogether with the RC for menu and dialog components.

Anyway, RC is useless for what i am doing myself to gain full control of my window, and especially when you need to change things on the fly without recompiling the code.

Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on January 12, 2017, 12:00:23 PM
Patrice,
  I know you have no personal use or interest but your opinion is highly respected.
I have conducted alot of trials with different compilers and I have yet to find one that produces smaller code than Visual c++ in conjunction with Fred's TCLib using resource dialogs as the display medium.
  That said I am not a TINY fanatic. I REALLY like José's CWindow framework and the 20k or so overhead is well worth it, but, I have always used a WYSIWYG window designer going all the way back to my dos and Win 3.1 days. Now I can have both.

James


Title: Re: Dialog rc To source code utility
Post by: Patrice Terrier on January 12, 2017, 12:53:43 PM
James

I have never been able to use TCLib within a standard VS 2015 Window project (no console).
If you have a SDK one, i would be glad to try it.

...
Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on January 12, 2017, 01:16:51 PM
Dlg2Src is updated with new link in first post.

James
Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on January 12, 2017, 02:10:54 PM
Quote from: Patrice Terrier on January 12, 2017, 12:53:43 PM
James

I have never been able to use TCLib within a standard VS 2015 Window project (no console).
If you have a SDK one, i would be glad to try it.

...

See: http://www.jose.it-berater.org/smfforum/index.php?topic=5180.0

James
Title: Re: Dialog rc To source code utility
Post by: Patrice Terrier on January 17, 2017, 10:23:31 PM
I did try to use TClib with a full SDK version of Address, and the resulting size looks very good.
Need to find a good replacement for vector in order to manage the dynamic array...
Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on January 17, 2017, 11:52:39 PM
Quote from: Patrice Terrier on January 17, 2017, 10:23:31 PM
I did try to use TClib with a full SDK version of Address, and the resulting size looks very good.
Need to find a good replacement for vector in order to manage the dynamic array...
There is one over on PellesC froum someplace. If you don't find it I'll take a look tomorrow .
http://forum.pellesc.de/index.php

James
Title: Re: Dialog rc To source code utility
Post by: Patrice Terrier on January 18, 2017, 10:22:15 AM
My idea was to use: new + delete[]
to allocate dynamically the global array.

But if there is something already written to add, remove, erase, that would save my time.
The only other thing that could enlarge the code is the use of printing.

I wrote a couple of TRIM functions that do not require the use of the string class, and thus keep the code size small, currently 22 Kb.

If you want i can post the VS2015 project in its current unfinished state.
(And tell me in which thread to post it).

...

Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on January 18, 2017, 10:53:38 AM
Patrice,
  Yes Thanks. Put it in the Discussion Section.
I like Fred's String class and just made a conversion (StringA.cpp) to ansi only I needed. My ansi sections in TCLib\tchar.h is not up to date.
James
Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on March 04, 2017, 06:25:53 PM
Because of some false browser malware site protection issues I have posted ResEd and it's help file to my bc9Basic github site:
http://jcfuller.github.io/bc9Basic/ResEd.zip
http://jcfuller.github.io/bc9Basic/ResEd.chm

Also I recompiled with VS2015 using STL regex and reduced the size considerably so you may want to re-download. Same code just different compilers.

The first Post has been updated also.
James
Title: Re: Dialog rc To source code utility
Post by: Frederick J. Harris on March 06, 2017, 04:13:36 PM
My intention was to code a replacement for C++ vectors for use with TCLib, but I've got so much going on in my life right now I don't know when I'll get to it.
Title: Re: Dialog rc To source code utility
Post by: Patrice Terrier on March 07, 2017, 09:26:04 AM
Why TClib helps to produce very small piece of code, its current status is too limited to produce real life application.

I did try to use it to produce 64-bit OpenGL visual plugins, but the lack of very basic math functions forced me to switch back to the classic <math.h>.
Thus my question is, do you know if there is a much ellaborated math.h include file that could be used with it?
Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on March 07, 2017, 10:54:32 AM
Patrice,
  Can you give me a list of the functions you need? I'm not sure I have the ability to add them but I can give it a go.

James
Title: Re: Dialog rc To source code utility
Post by: Patrice Terrier on March 07, 2017, 01:26:33 PM
For example: timer, sqr, rnd, sin, cos, abs, mod, just to give a few (must work with: int, float, double).

I have attached a simple LaserBeam OpenGL visual plugin, to compile as a DLL, for you to try.
(VS 2015 community project)

...
Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on March 07, 2017, 03:57:21 PM
Patrice,
  rnd,mod and timer are not c++ intrinsics that I'm aware of??
I am working on the trig functions now and they appear to be working fine.

James

Title: Re: Dialog rc To source code utility
Post by: Patrice Terrier on March 07, 2017, 04:12:58 PM
 rnd,mod and timer are not c++ intrinsics that I'm aware of??

timer:
time(NULL);

rnd:
rand()

RANDOMIZE TIMER:
srand((DWORD) time(NULL));

mod:
% // for int
fmodf // for float
fmod // for double

Title: Re: Dialog rc To source code utility
Post by: Frederick J. Harris on March 07, 2017, 06:13:31 PM
I'm going nuts with issues now and can't get to it, but the math.h functions could be easily added to TCLib's capabilities.  The issue with that is as follows.  In my original work on TCLib my intention was to recode everything myself from scratch that I needed from the C Runtime.  The only place I got stuck was on Math.h, specifically pow(), i.e., raising a floating point number to a floating point exponent.  That is one partuicular function I absolutely needed.  I didn't know how to do it.  I downloaded the C Runtime source from GCC, but I simply ran out of time trying to figure it out.

Next step or movement in the drama was my discovery that Microsoft's Windows operating systems automatically loads msvcrt.dll into every GUI process it starts.  If you don't believe me simply run Mark Russinovitch's utility that shows all the dlls loaded into a process.  What you'll find is that every GUI process - even the very simplest with just a blank Window, has msvcrt.dll loaded into the process.  Not true for console processes but absolutely true for GUI processes that make calls into user32.lib and gdi32.lib.

Having absorbed that reality it dawned on me that if that's the case - and it is, why should I be wearing myself out writing code replacements for functions that are loaded into my process anyway and which I'm powerless to eliminate?

The creators of mingw felt likewise and that's where they get their C Runtime functionality, i.e., from msvcrt.dll.  For their part Microsoft isn't thrilled about that outcome, because its their position that a Windows installation isn't a 'Delivery Channel' for the C Runtime.  They would prefer folks use the 'versioned' instances of the C Runtime provided with Visual Studio, statically link against them, or provide them to users as redistributables. 

But all the C Runtime functions are there and msvcrt.dll is part of the operating system, i.e., it'll always be there.  Its a protected operating system file.    I've stated elsewhere that Bob Zale up through version 9 of the Windows compiler included a copy of msvcrt.dll in his /bin subdirectory of his installation, and since noting that, I've always been curious what use he made of it internally. 

In any case, my present versions of TCLib get most of their stdio functionality through function pointers to the functions in msvcrt.dll rather than through code I've written.  That is how pow() works too.  The trig and other functions could easily be implemented likewise.  I didn't because I don't do much surveying work anymore.  I used to years ago, and may again at some point, but I didn't need it right now.  Actually, its so easy to add it I could do it in a few minutes.
Title: Re: Dialog rc To source code utility
Post by: James C. Fuller on March 07, 2017, 07:03:53 PM
Fred,
  Thanks for the insight. I am in the process of adding the math functions. Piece of cake. :)
I know you are busy with personal stuff  and preparing  for retirement. We can tackle more and interesting stuff for TCLib after you retire.

James

Title: Re: Dialog rc To source code utility
Post by: Frederick J. Harris on March 08, 2017, 04:16:15 AM
Thanks for taking a look at it Jim!  Its just a matter of looking at what I did in the crt... functions with InitStdio() and InitMath() and using those architectures/templates for the other Math.h functions.  Sounds like you've got it. :)
Title: Re: Dialog rc To source code utility
Post by: Mike Lobanovsky on March 08, 2017, 08:31:35 AM
Frederick,

Your observation is absolutely correct and logical. There's no need to re-invent the wheel since msvcrt.dll has always been, and will continue to be, a dedicated user space system library on every Windows machine regardless of OS version since at least Windows'95 (might be even earlier than that; too lazy to check out myself now) onwards. Most of monkey work about classic C functionality is usually initiated by those devs who are obsessed with their code portability to other platforms. msvcrt.dll supports all common math and trig that one may ever need in one's general purpose applications. Versioned runtimes of later Visual Studios are normally only needed if you tend to get irritated too much by the VS obtrusive warnings about your using "deprecated" vocabulary, or if your customers/contractors appear to be overly picky in their design docs and technical specs.

Moreover, msvcrt.dll is guaranteed to remain backward and forward compatible throughout all Windows versions.

On the other hand, there is one more system-wide C language runtime called crtdll.dll. This one is meant to interact with the kernel space processes and might not be ABI compatible between different Windows versions, depending on the particular design solutions in a version's kernel. Even though it may seem to offer functionality similar to that of msvcrt.dll, it is usually a bad (unsafe) idea to link a user app directly against it unless your creation is a native application (a.k.a. driver) that would usually rely heavily on a particular kernel implementation and/or computer hardware.

In most cases, msvcrt.dll serves as a mere proxy between an ordinary user space application and the crtdll.dll-to-kernel32.dll bundle, which proxy ensures everlasting and transparent API/ABI compatibility and interoperability of any user space code with the underlying kernel space processes.

That said, and provided your code uses at least one explicit or transparent call to either user32 or gdi32 library API, you may safely assume that msvcrt.dll will get mapped into your process memory automatically as well regardless. So, why not use it for your own purposes to the fullest if your app isn't intended as a hermaphrodite Jack of all trades on two masters' errand? :)
Title: Re: Dialog rc To source code utility
Post by: Frederick J. Harris on March 10, 2017, 12:39:09 AM
Thanks for the input Mike.  I never knew much about NTDll.  I've seen it show up in debuggers, but didn't know much about it.