Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 22nd, 2004, 09:50 AM
Authorized User
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to use win32 API?

I want to make my winform flash in taskbar or statusbar
if i have to use a win32APi ?
if so ,would flashwindowEx works?
how to use it?
Is there any Example?

Old June 23rd, 2004, 02:12 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma

Include this namespace

using System.Runtime.InteropServices;

Declare the struct like this in your project namespace

    namespace XYZ
    public struct FLASHINFO
        public Int32 cbSize;
        public IntPtr hwnd;
        public int dwFlags;
        public UInt32 uCount;
        public int dwTimeout;

And declare this function in your class

        public static extern bool FlashWindowEx(
            ref FLASHINFO fInfo);

and then wherever you wanna call FlashWindowsEx use the code similar to this one

                FLASHINFO fInfo = new FLASHINFO();
                fInfo.cbSize = sizeof(FLASHINFO);
                fInfo.dwFlags = 2;
                fInfo.hwnd = this.Handle;
                fInfo.uCount = 2;
                fInfo.dwTimeout = 0;
                bool result = FlashWindowEx(ref fInfo);

                if (result)
                    MessageBox.Show("Called successfully");

Open winuser.h and see the values for different flags

To be able to build this project you will have to go to
Project->YourProject Properties... , Configuration Properties->Build
and turn the option "Allow Unsafe Blocks" in the list on the right side to True

I know... I'm myself not too pleased with the unsafe block that I had to insert in the code, I'm trying to find a way around, but you have got the lead too, so if your strike first, do let me know.


Ankur Verma
.Net and C++ Specialist
Wiley Tech Support

Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between win32 API and FCL adie BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 0 July 26th, 2007 05:56 PM
How to read C# IntPtr struct in Win32 API Lookie VB How-To 1 February 24th, 2005 07:29 PM
Win32 API Programming visit_anand_it Visual C++ 2 September 7th, 2004 11:46 PM
Fonts going crazy (win32 API GUI) afradley C++ Programming 0 April 10th, 2004 09:09 AM
Need help in writing a C program using win32 API rameshbabumv C++ Programming 0 March 10th, 2004 05:46 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.