コード例 #1
0
ファイル: io_printer.c プロジェクト: VlaBst6/fbc
static void
fb_hPrinterBuildListLocal( FB_LIST *list )
{
    int i, count;
    PRINTER_INFO_2 *printers = GetPrinters(&count);
    for( i=0; i!=count; ++i ) {
        PRINTER_INFO_2 *printer = printers + i;
        if( printer->pServerName==NULL ) {
            /* get the port from local printers only */
            LPTSTR pPortName = printer->pPortName;
            LPTSTR pFoundPos = strchr(pPortName, ',');
            while (pFoundPos) {
                DEV_PRINTER_DEVICE* node;
                *pFoundPos = 0;

                /* We only add printers to the list that are attached to
                 * an LPTx: port */
                if( strncasecmp( pPortName, "LPT", 3 )==0 ) {
                    node = fb_hListDevFindDevice( list, pPortName );
                    if( node==NULL ) {
                        fb_hListDevElemAlloc ( list, pPortName, printer->pPrinterName );
                    }
                }

                pPortName = pFoundPos + 1;
                while( isspace( *pPortName ) )
                    ++pPortName;
                pFoundPos = strchr(pPortName, ',');
            }
            if( strncasecmp( pPortName, "LPT", 3 )==0 ) {
                DEV_PRINTER_DEVICE* node = fb_hListDevFindDevice( list, pPortName );
                if( node==NULL ) {
                    fb_hListDevElemAlloc ( list, pPortName, printer->pPrinterName );
                }
            }
        }
    }
    free(printers);
}
コード例 #2
0
ファイル: io_printer.c プロジェクト: VlaBst6/fbc
static int
fb_hPrinterBuildListOther( FB_LIST *list, int iStartPort )
{
    char Buffer[32];
    int i, count, iPort = iStartPort - 1;
    PRINTER_INFO_2 *printers = GetPrinters(&count);

    for( i=0; i!=count; ++i ) {
        PRINTER_INFO_2 *printer = printers + i;
        if( fb_hListDevFindName( list, printer->pPrinterName )==NULL ) {
            DEV_PRINTER_DEVICE* node;
            do {
                ++iPort;
                sprintf( Buffer, "LPT%d", iPort );
                node = fb_hListDevFindDevice( list, Buffer );
            } while( node!=NULL );

            fb_hListDevElemAlloc ( list, Buffer, printer->pPrinterName );
        }
    }
    free(printers);

    return iPort + 1;
}
コード例 #3
0
ファイル: kguimingw.cpp プロジェクト: CarlHuff/kgui
void kGUISystemMINGW::Init(HINSTANCE hInstance,int nCmdShow)
{
	int startwidth,startheight;
	int fullwidth,fullheight,maximages;
	MSG msg;

	m_showwindow=false;
	m_mousex=0;
	m_mousey=0;
	m_mousewheeldelta=0;
	m_waskilled=false;
	m_mouseleftbutton=false;
	m_mouserightbutton=false;
	GetPrinters();

	// Initialize global strings
	kGUI::Trace("------------------------------------------------------------------------------\n");
	LoadString(hInstance, IDS_APP_TITLE, m_szTitle, MAX_LOADSTRING);
	kGUI::Trace(" LoadString(hInstance, IDS_APP_TITLE, m_szTitle, MAX_LOADSTRING);\n");
	LoadString(hInstance, IDC_APP_NAME, m_szWindowClass, MAX_LOADSTRING);
	kGUI::Trace(" LoadString(hInstance, IDC_APP_NAME, m_szWindowClass, MAX_LOADSTRING);\n");

	{
		WNDCLASSEX wcex;

		wcex.cbSize = sizeof(WNDCLASSEX); 

		wcex.style			= CS_HREDRAW | CS_VREDRAW;
		wcex.lpfnWndProc	= (WNDPROC)WndProc;
		wcex.cbClsExtra		= 0;
		wcex.cbWndExtra		= 0;
		wcex.hInstance		= hInstance;
#if defined(IDI_LARGEICON)
		wcex.hIcon			= LoadIcon(hInstance, (LPCTSTR)IDI_LARGEICON);
#else
		wcex.hIcon=0;
#endif
		wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
		wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
		wcex.lpszMenuName	= 0;
		wcex.lpszClassName	= m_szWindowClass;
#if defined(IDI_SMALLICON)
		wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALLICON);
#else
		wcex.hIconSm=0;
#endif
		kGUI::Trace(" RegisterClass(&wcex);\n");
		RegisterClassEx(&wcex);
	}

	/* get the full screen size */
	fullwidth=GetSystemMetrics(SM_CXSCREEN);
	fullheight=GetSystemMetrics(SM_CYSCREEN);

	/* this is the size of that app window, use fullscreen */
	/* unless overridden by the user requested dimensions */
#ifdef	DEFSCREENWIDTH
	startwidth=DEFSCREENWIDTH;
#else
	startwidth=fullwidth;
#endif
#ifdef	DEFSCREENHEIGHT
	startheight=DEFSCREENHEIGHT;
#else
	startheight=fullheight-35;
#endif
#ifdef DEFMAXIMAGES
	maximages=DEFMAXIMAGES;
#else
	maximages=200;
#endif

	m_lasttickcount=GetTickCount();
	
	m_hInst = hInstance; // Store instance handle in our global variable

	kGUI::Trace(" hWnd = CreateWindow(m_szWindowClass, m_szTitle, WS_POPUP | WS_VISIBLE, 0, 0, ScreenWidth, ScreenHeight, NULL, NULL, hInstance, NULL);\n");
 
	m_hWnd = CreateWindow(m_szWindowClass, m_szTitle, WS_POPUP | WS_VISIBLE /*|WS_EX_LAYERED*/ ,
	    (fullwidth-startwidth)/2, (fullheight-startheight)/2, startwidth, startheight, NULL, NULL, hInstance, NULL);

	if (!m_hWnd)
	{
		kGUI::Trace(" Last Function failed, program aborting!\n");
		return;
	}
	// Allocate BMP data for screen
	kGUI::Trace(" GetClientRect(hWnd,&m_WinRect);\n");
	GetClientRect(m_hWnd,&m_WinRect); 

	/* initialize kGUI engine */
	kGUI::Trace(" kGUI::Init(m_WinRect.right-m_WinRect.left,m_WinRect.bottom-m_WinRect.top);\n");
	if(kGUI::Init(g_sys,m_WinRect.right-m_WinRect.left,m_WinRect.bottom-m_WinRect.top,fullwidth,fullheight,maximages)==false)
	{
		kGUI::Trace(" Last Function failed, program aborting!\n");
		return;
	}

//	kGUI::Trace(" LoadAccelerators(hInstance, (LPCTSTR)IDC_APP_NAME);\n");
//	m_hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_APP_NAME);

	kGUI::Trace(" WSAStartup(0x0202,&m_SockData);\n");
    if(WSAStartup(0x0202,&m_SockData))
	{
		kGUI::Trace(" error initing WSAStartup;\n");
		return;
	}

	/* call the application init code */
	kGUI::Trace(" AppInit();\n");
	AppInit();

	/* show the window if the application has not already done so */
	if(m_showwindow==false)
		ShowWindow();

	kGUI::Trace(" UpdateWindow(m_hWnd);\n");
    UpdateWindow(m_hWnd);

	kGUI::Trace(" Draw(m_hWnd);\n");
    Draw(m_hWnd,0,0,0,0);

	kGUI::Trace(" SetTimer(m_hWnd, 0, 1000 / FRAMES_PER_SECOND, NULL);\n");
    SetTimer(m_hWnd, 0, 1000 / FRAMES_PER_SECOND, NULL);

	// Main message event loop:
	kGUI::Trace(" Entering Main loop: GetMessage(&msg, NULL, 0, 0);\n");
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
//		if (!TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg)) 
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	kGUI::Trace(" Exited Main loop, program done.\n");
}