Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Converting Unicode data from the Clipboard to a character string using a given code page
Enumerating data formats currently available on the clipboard
Custom FTP Class for Visual FoxPro application
Winsock: sending email messages (SMTP, port 25)
Splash Screen for the VFP application
Detecting changes in connections to removable drives (VFP9)
How to download a file from the FTP server using FtpGetFile
How to activate Windows Calculator
Custom HttpRequest class (WinHTTP)
Establishing connection using the SQLDriverConnect
How to convert a bitmap file to monochrome format (1 bpp)
How to put a vertical text scrolling on the form (a movie cast)
Mapping and disconnecting network drives
Using Font and Text functions
Displaying bitmap using the AlphaBlend function
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Using WM_COPYDATA for interprocess communication (VFP9)
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
How to play AVI file on the _screen
Using the ChooseColor function

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
Not much a difference from the native VFP function GetColor().
 
using System;
using System.Runtime.InteropServices;
 
namespace ChooseColor
{
    class Program
    {
        [StructLayout(LayoutKind.Sequential)]
        public struct CHOOSECOLOR
        {
            public Int32 lStructSize;
            public Int32 hwndOwner;
            public Int32 hInstance;
            public Int32 rgbResult;
            public IntPtr lpCustColors;
            public Int32 Flags;
            public Int32 lCustData;
            public Int32 lpfnHook;
            public Int32 lpTemplateName;
        }
 
        static void Main(string[] args)
        {
            CHOOSECOLOR choosecolor = new CHOOSECOLOR();
 
            choosecolor.lStructSize = Marshal.SizeOf(choosecolor);
            choosecolor.hwndOwner = 0; //GetDesktopWindow();
            choosecolor.rgbResult = 0x808080;
            choosecolor.lpCustColors = Marshal.AllocCoTaskMem(64);
            choosecolor.Flags = 3;
 
            ChooseColorA(ref choosecolor);
            //get the color from rgbResult member
       }
 
        [DllImport("comdlg32.dll")]
        public static extern int 
            ChooseColorA(ref CHOOSECOLOR pChoosecolor);
 
        [DllImport("user32.dll")]
        public static extern int GetDesktopWindow();
    }
}
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1283 bytes  
Created: 2002-01-25 19:49:18  
Modified: 2008-03-20 15:58:27  
Visits in 7 days: 158  
Listed functions:
ChooseColor
GetActiveWindow
GlobalAlloc
GlobalFree
Printer friendly API declarations
My comment:
WIth the ChooseColor you have some more control on the form presentation, but not its positioning.

16 custom colors are available for reading and writing through a memory block, which -- if you are interested in -- you have to allocate and release directly.

Using the VFP native GetColor function you can access the custom colors as well, but only changing their values within the Color dialog is available. I guess that VFP keeps that array in its memory during the whole session, exclusively to be used in the ChooseColor calls. To my knowledge there is no regular way to reach it.

Then, not many advantages this function gives to dump the good old GetColor, which is still present unchanged in each VFP version.
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (23.22.76.170)
30.58 min.Example: 'Using SQLBrowseConnect to connect to a data source through a number of iterative calls (SQL Server)'
30.65 min.Example: 'Listing child windows for the Windows desktop'
21.32 hrs.Example: 'FindText -- the hopeless and useless Common Dialog'
22.49 hrs.Function: 'GdipDeleteMatrix'
1 day(s)Example: 'How to make a VFP form fading out when released (GDI+ version)'
 Function: 'GetCursorPos'
 Example: 'Displaying all TCP connections for the local system'
 Function: 'htons'
2 day(s)Function: 'CopyIcon'
 Example: 'Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form'
Google
Advertise here!