Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 22nd, 2004, 09:50 AM
Authorized User
 
Join Date: Apr 2004
Location: xiamen, fujian, China.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to use win32 API?

Hello,
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?


Reply With Quote
  #2 (permalink)  
Old June 23rd, 2004, 02:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Default

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

        [DllImport("user32.dll")]
        public static extern bool FlashWindowEx(
            ref FLASHINFO fInfo);


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

                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.

Regards

Ankur Verma
.Net and C++ Specialist
Wiley Tech Support
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:19 AM.


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