ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

GlassPrompt 1.1

<< < (2/7) > >>

MilesAhead:
If anyone is tempted to play around with FreeBasic, I posted the v. 1.1 source code for GlassPrompt on the forum:

http://www.freebasic.net/forum/viewtopic.php?t=16107

It's pretty flexible and interesting.  It has classes but I believe inheritance is not implemented.  The libraries include lots of WinAPI stuff like ShellExecute, FindWindow etc..

It also has user defined types so creating a struct to make a WinAPI call that's not in the library is not difficult.  Also some sort of operator overloading. I'm still new to it so resort to the online site for accurate info. :)

MilesAhead:
I had vs2008 Express with SP1 kicking around so I put vc++ on.  It's been years so I thought time to scrape some of the rust off. :)

Starting with something wicked easy, doing Glass in vc++. It uses the same "trick" FreeBasic programmers use of compiling a console app as Win32 to avoid the command prompt flashing up when the program runs.


--- ---#include "stdafx.h"
#include <windows.h>
#include <dwmapi.h>
#include <shellapi.h>

BOOL VistaOrHigher()
{
    return((LOBYTE(LOWORD(GetVersion()))) >= 6);
}


int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
    BOOL isEnabled = FALSE;

    if(! VistaOrHigher())
      return 1;
    DwmIsCompositionEnabled(&isEnabled);
    if(! isEnabled)
      return 1;
    if((int)ShellExecute(0,L"open",L"cmd.exe",0,0,SW_HIDE) < 33)
      return 1;
    Sleep(50);
    HWND h = FindWindow(L"ConsoleWindowClass",0);
    if(! h)
      return 1;
    DWM_BLURBEHIND bb = {0};
    bb.dwFlags = 1;
    bb.fEnable = TRUE;
    bb.hRgnBlur = (HRGN)h;
    bb.fTransitionOnMaximized = TRUE;
    DwmEnableBlurBehindWindow(h,&bb);
    SetWindowText(h,L"GlassPrompt");
    ShowWindow(h,SW_SHOWNORMAL);
    SetForegroundWindow(h);
    return 0;
}

edit: Suprised me a bit.  Compiled as stand-alone .exe with a low res icon and version info, only 17KB.

Eóin:
Is it the low size that surprises you? One thing that's happening there is you're dynamically linking against the VC runtime, so technically anyone using you're application needs to have, in this case, the Microsoft Visual C++ 2008 SP1 Redistributable Package (x86) installed. Of course I tend to believe that's a good thing and that everyone should dynamically link against the VC runtime, it would cut down on physical memory usage when running lots of apps all using the same runtime.

Or are you surprised at the large size? After all, with just a few API calls, there's no reason such an app need be over 4kb which is generally the minimum unless you do some fancy manual linking.

MilesAhead:
FreeBasic does the same program in about 9KB if you don't use resources, such as icon, version info etc..

This app should be stand-alone .exe and came in about the same, until I added an icon and version info. It's not managed code.

Eóin:
Ah I see, kinda impressive for FreeBasic assuming that 9kb includes the interpreter.

If should you want small size and standalone-ness look into using a smaller custom CRT, for example Tiny C Runtime Library.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version