How Can I make a Frame AlwaysOnTop using Native Methods

Hi Have Developed The Sample Application for Always On Top that is compiled successfully even executed without any exception, but the frame is not always On Top As I required.
I m m using
-Windows XP 2004
-J2SDK-1.4.2
-Microsoft Visual C++ 6.0
The following is the code
and all files mentioned right after the code:
1- MyFrame.java
import java.awt.*;
import javax.swing.*;
public class MyFrame extends JFrame{
     static { System.loadLibrary("MyFrame"); }
     public MyFrame() {
          super();
     public void setAlwaysOnTop(boolean b) {
          int hwnd = getNativeWindowHandle(this);
          setAlwaysOnTop(hwnd, b);
     private native int getNativeWindowHandle(Window window);
     private native void setAlwaysOnTop(int hwnd, boolean flag);
2- AtTopTestFrame.java
public class AtTopTestFrame {
     public static void main(String s[])
          MyFrame frm = new MyFrame();
          frm.setSize(300,300);
          frm.show();
          frm.setAlwaysOnTop(true);
3- MyFrame.cpp
#include <jni.h>
#include <jawt.h>
#include <afxwin.h>
#include <windows.h>
#include "MyFrame.h"
#include "jawt_md.h"
JNIEXPORT jint JNICALL
Java_MyFrame_getNativeWindowHandle(JNIEnv *env, jobject jobj, jobject window)
     JAWT awt;
     awt.version = JAWT_VERSION_1_4;
     jboolean result = JAWT_GetAWT(env, &awt);
     if (result == JNI_FALSE)
          return 105;
     JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, window);
     if (ds == 0)
          return 106;
     jint lock = ds->Lock(ds);
     if ((lock & JAWT_LOCK_ERROR) != 0)
          return 107;
     JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
     if (dsi == 0)
          return 108;
     JAWT_Win32DrawingSurfaceInfo* dsiwin = (JAWT_Win32DrawingSurfaceInfo*) dsi->platformInfo;
     jint ret = reinterpret_cast<jint>(dsiwin->hwnd);
     ds->FreeDrawingSurfaceInfo(dsi);
     ds->Unlock(ds);
     awt.FreeDrawingSurface(ds);
     return ret;
JNIEXPORT void JNICALL
Java_MyFrame_setAlwaysOnTop(JNIEnv *env, jobject jobj, jint hwnd, jboolean flag)
     if (flag)
          SetWindowPos((HWND) hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
     else
          SetWindowPos((HWND) hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
Steps I performed For compilation
1-MyFrame.class (with command "javac MyFrame.java")
2-MyFrame.h (with command "javah MyFrame" )
3-MyFrame.obj(with command "cl -IE:\j2sdk1.4.2_03\include -IE:\j2sdk1.4.2_03\include\win32 /c -LD -IMyFrame.h MyFrame.cpp")
4-MyFrame.dll(with command "link /DLL MyFrame.obj E:\j2sdk1.4.2_03\lib\jawt.lib")
5-AtTopTestFrame.class (with command "javac AtTopTestFrame.java")
6-Execute AtTopTestFrame.class (with command "java AtTopTestFrame")
After the steps performed on the above three files. I got a frame appeared as usual but that is not AlwaysOnTop as I required.
I m again telling that I m using
-Windows XP 2004
-J2SDK-1.4.2
-Microsoft Visual C++ 6.0
Can any one take a review of this code and please help me. It is most required for my assignment to be completed. I just required my frame AlwaysOnTop.
Thanks
Khurram.

HI guys
Can any one help me in above problem
Thanks
Khurram

Similar Messages

  • How can i make a signature by using lightroom? , is it possible?

    how can i make a signature by using lightroom? , is it possible?

    To can create a text identity plate in LR but to create a graphical version
    requires Photoshop

  • How can i get a file header using this method cl_gui_frontend_services= gui

    Hi Experts,
    How can i get a file header using this method cl_gui_frontend_services=>gui_download
    Thanks
    Basu

    Hi,
    You can use the FM - GUI_DOWNLOAD to specify the headers. It can be done in the following manner -
    TYPES: BEGIN OF ty_head, "Structure for header
                 h(10) TYPE c,
                 END OF ty_head.
    DATA: it_head  TYPE TABLE OF ty_head WITH HEADER LINE.
    "Adding header details
    it_head-h = 'Field1'.
    APPEND it_head.
    it_head-h = 'Field2'.
    APPEND it_head.
    it_head-h = 'Field3'.
    APPEND it_head.
    it_head-h = 'Field4'.
    APPEND it_head.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                        = p_file
       filetype                        = 'ASC'
       write_field_separator           = 'X'
       header                          = '00'  "<= note this
      TABLES
        data_tab                        = it_tab
       fieldnames                      = it_head[] "<= Pass your header table here
    EXCEPTIONS
       OTHERS                          = 1.
    Hope this helps.
    Regards,
    Himanshu

  • How can I make SP2010 site responsive using IE8?

    Hi everyone,
    My company use a range of laptops and screen resolutions and I need my SP site to fit to whichever screen it is being viewed on.  I have followed lots of threads saying to use media tags and CSS3 but I have IE8 which isn't compatible.  Upgrading
    to IE9 isn't an option.
    Has anyone got any solutions?  Is the answer a fixed width centre and the outer white space altering? (and if so how can I make that happen?!)
    Many thanks
    Natalie

    Hi Pinky,
    Thanks for posting your query, Kindly refer below mentioned URLs for this issue.
    http://www.graphicalwonder.com/?p=903
    http://kyleschaeffer.com/mobile/v5-responsive-html5-master-page/
    I hope this is helpful to you. If this works, Please mark it as Answered. 
    Regards, 
    Dharmendra Singh (MCPD-EA | MCTS) 
    Blog :
    http://sharepoint-community.net/profile/DharmendraSingh

  • How can i make a slideshow to use in muse where each slide has its own hyperlink

    I want to make a slideshow to use in muse where each slide has its own hyperlink to another page in the site.
    example here: Genesis Bicycles - Easton PA
    I see how slideshows can be made in muse, but haven't seen where you can assign a hyperlink to each image. 
    I would like it to be html5 compatible.
    Thanks ,
    mark

    Hey Mac, thanks for the feedback. I did some research on composition widget, still not finding how I can use that to make a slide show like the one on www.Genesisbicycles.com home page , could you elaborate on how to or maybe link a tutorial for me.  It would be a big help.
    mark

  • How can i make a web VI using web UI buider

    Hi,
    I have installed a web UI builder and now i'm trying to get rid of it by going through tutorials.
    My biggest problem is i'm unable to understand the concept making web pages,
    And my+ requirement is I have a servo motor and by running this motor plots which are being made on a graph i want to display it in a web browser and anyone can see it without a control.
    Can anyone help me that how can i use WEB UI Builder efficiently to the above task.
    Regards
    Mangesh
    =========================================
    Please remember to accept a solutions and show your appreciation by giving Kudos to helpful messages...
    Mangesh D.
    CLAD | Project Engineer
    ==
    VIPM, LabVIEW 8.2, 2009, 2011SP1, 2012, 2012SP1, 2013, cRIO,cDAQ, PXI, ELVIS, Multisim, Smart Camera....
    Solved!
    Go to Solution.

    Thanx altenbach
    I don't have a evaluation copy of Web UI Builder and now with mty efforts i'm able to run my LabVIEW VI into web UI Builder by using web services.
    But the fact is i'm unable to build and deploy it( as it is only in full version). 
    My problem is by building and deploying my Web UI program what can i do with that.can i possibly publish it on Website i'm having?
    Regards
    =========================================
    Please remember to accept a solutions and show your appreciation by giving Kudos to helpful messages...
    Mangesh D.
    CLAD | Project Engineer
    ==
    VIPM, LabVIEW 8.2, 2009, 2011SP1, 2012, 2012SP1, 2013, cRIO,cDAQ, PXI, ELVIS, Multisim, Smart Camera....

  • How can I make Picture frame my automatic lock screen

    I would like to be able to set up my iPad 2 so that when it's locked in the dock, it will automatically start picture frame isntead of having a still picture for the bacground. Is that possible? Thanks for the help!

    Can't make it automatic, but it's just two clicks away: Home button, then the flower icon button next to the unlock slider.

  • How can I play video on Android using native player?

    Is there a way to tell android to open my mp4 (either in assets or on external sd)  with it's native video player?
    Just like if I tap this (mp4) file in any android file manager.
    reasons:
    1 - I don't want to write my own player (especially when I have one built in)
    2 - I assume playback experience may be better when playing large file NOT through the AIR.
    So, can I  make something like "NativeApplication.execute(pathToMp4)"?

    Check the hardware acceleration mode you have set. Try to use "direct" acceleration as this will choose between GPU and CPU to render and is most compatible. The setting is in the XML file generated for the app:
    <!-- The render mode for the app (either auto, cpu, gpu, or direct). Optional. Default auto -->
    <renderMode>direct</renderMode>
    And no the device is absolutely not guaranteed to record compatible video at all. Browsers go by browser standards and video recording goes via manufacturer hardware and software limits, features and compatibility. It entirely depends on what you're doing with the video and the mode it is recorded in. If the user checks off the record CIF MMS compatible video and records in that it will not be visible to many browsers. Audio is almost always recorded in ultra-light mp3 or aac so that's why you hear it.
    Android allows you to install many different browsers. Did you install any or set any other browser as the alternate default browser? When you run the video from a file manager you may be running an alternate, capable browser for the codec. AIR may use the native built-in browser. Also it may not load the video into a browser for playback at all as I would suspect a video would be mapped to the devices default media player and not a browser at all. Unless you're able to select the video and explicitly tell it to open in a browser I feel you're actually looking at the video in the "Video" app of your device, which will be compatible with the codec.
    A simple way to check browser compatibility is to copy the video to your computer, upload it to a web server and see how it plays on various desktop browsers. If any of them have black video and only play sound, you know it's a codec issue.

  • How can I make a countdown timer using After Effects

    I'd like to make a video that has a timer that counts down one second at a time. I need one starting at 5:00 (five minutes). Is there a way to easily do this in After Effects without having to manually change the text every second?
    Thanks.

    I'm glad that you found a solution, but I thought that you might appreciate a suggestion of another approach.
    Colin Braley provides a tutorial and example project on
    his website that show how to use an expression on the Source Text property to animate text to overcome some of the limitations of the Numbers effect.
    There's a similar example in the
    "Example: Animate text as a timecode display" section of After Effects Help.
    Here are some Community Help searches that can lead you to some ideas, too:
    Community Help search for 'countdown timer'
    Community Help search for 'digital countdown timer'

  • HT1461 How can you make more 'Ram' available using bootcamp, on the windows side of things??

    Hey, i recently bought an iMac 20.5' (i5) and it came with 4gb Ram
    I am a music producer but the program i use is windows based, so i got bootcamp, all that works fine
    but ive been working on a new song for a while now and the prgoram has an 'indicator' showing how much CPU usage % and ram is being used.
    it is now at 1956mb! which should efffect because i have 4gb! right!??.. no it says (in windows sytem) 2.3gb (available)....
    So i went out and bought an extra 4gb, followed the instructions and Ram went int easy!!. I log onto Mac and yep 8 GB Of RAM!!
    so then i log into windows (through bootcamp ofcourse) and still 2.3 gb available....
    anyone know if i can make more avaible?? or do i have to reinstall windows through bootcamp???
    Thankyou
    P.S. 32 but windows 7 is what i use

    Windows installed using Boot Camp uses all your comptrer's resources.
    Windows 7 32 bit can only use about 3 GB of RAM. The limitation is that 32 bits can not address more than this. If you want to address and use more RAM then you need Windows 64 bit.

  • How can I make an E-Book using InDesign?

    I initally assembled an ebook using Microsoft Word and uploaded the file to BookBaby along with the cover design as a separate image file. The E-book is a relatively simply layout, 100 color cartoons and a text "forward" on first page. However, BookBaby said NOT....I needed to resend the book in a "fixed format". Thus my decision to use InDesign. However, since I've never used InDesign for any work like this I am curious if anyone can help or at the very least, recommend decent links at how I could initially begin to restructure my entire book? As mentioned, it's a relatively simple layout from an asthetics standpoint - - 100 separate cartoons in full color that are 700 pixels wide in JPEG format. Then the "forward" and that full color cover with text already in the image for embedding as the cover design.
    Any insights, thoughts, feedback and / or constructive criticism would be greatly appreciated.

    Normally a paid-for book from the iBookstore can only be read on an Apple device, it tells you that in the requirements section of the purchase page.

  • How can I make a image slider using Dreamweaver? Is there any image slider widget I could use?

    I was browsing through the web when I saw a website which had a really cool image slider. I don't have any idea of how to develop anything similar, but I was wondering if maybe dreamweaver had any widget that has already been developed by someone else that is open source for everyone else to use. Is there anything any?

    Ken is referring to a "roll your own" slider that works great. There are lots of those.
    None of those are built in to Dreamweaver. None of those will give you a panel within Dreamweaver with which you can build them.
    Project Seven does sell widgets that are Dreamweaver extensions.
    Adobe is offering another one for free (and you get additional function if you buy it).
    Extend Studio offers Power Slider (with a free trial).
    And there is Nivo Slider.
    These are extensions that plug in and extend what Dreamweaver can do.

  • How can I make a 3D cube using only Flash CS4?

    Looking for a tutorial on how to make a 3d cube. The best one I found was how to make a book, which is three sides short of a cube. If worse comes to worse I think there's a way to take two identical movie clips with three sides each and pivot them around the same point to form a cube. But if there's some solid instruction anyone could provide or a link, it would save me countless hours of guessing testing and revising.
    Thanks!

    Hi,
    Wire in '448' to the 'New Permissions' of the Access Rights VI. This will set the file as readable, writable and executable. I just tried this (on WinNT, though).
    The 'permissions' parameter is a 16-bit integer where the least 9 bits are used. Of these, for Windows, bits 8, 9, and 10 (0-indexed) are important (i.e. if these are set = integer 448). See online Help for full details.
    Hope this helps,
    Khalid

  • How can I make the frame advance after an flv is done playing?

    I've got an flv that we're streaming from a website and I
    want the swf to advance to the next frame once the video is done
    playing. I've looked all over for a way to do this, but I can't
    find anything. Does anyone know of some actionscript code that will
    work?
    Thanks.

    Nevermind. I figured it out for myself. I used this code
    right on top of the player itself.

  • How can I make an updatable website using Adobe?

    Hello,
    I am looking to create a website to host my YouTube videos, photographs, other information and a blog, and possibly an online store in the future. I don't know where to begin with this because I'm not sure how easy websites are to update once they have been uploaded (unless you use an online website maker).
    Could someone please advise me on what software I should use (I have created a business website for someone using Muse in the past but it doesn't need regular updating), and also how I should have the website hosted?
    Many thanks,
    Ryan

    Ask in the iWorks forum here:
    https://discussions.apple.com/community/iwork

Maybe you are looking for

  • Mini dvi to dvi adapter not working with monitor

    arright *** i got a mini dvi to dvi adapter which is connected to my vga monitor through a vga to dvi adapter. The computer recognizes the monitor in display preferences, but the monitor doesn't display anything it just sits in standby mode... any id

  • How can I change the User Password expiry date

    Hi, I want to know how can I change the password expiration date of my user without changing his password. For eg:- User password expires on 12th May 2007. I want to extend to 12th Jun 2007. Is there any option in Oracle. Alter User <USERNAME> passwo

  • How to copy and  paste the data directly from the excel to the PDF?

    hi, I have found the same question on the link: How to copy excel sheet to pdf form? But I didnt get my answer through that forum. My requirement is dat I should copy the data from excel sheet and directly paste it to PDF form. When I am trying to co

  • Receiving too small photos MMS Nokia N82

    When I receive MMS photos they are 120x160 (14-16 kB) regardless of the size sent. When a photo is sent simultaneously to my e-mail, the e-mailed photo remains at the sent size 480x640 (40kB) but the one to my N82 is degraded. I have updated MMS-sett

  • Separator line in alv grid custome toolbar

    I had created a toolbar in alv grid through CLASS cl_alv_grid_handler IMPLEMENTATION. I would like to separate the control by separator line please suggest me how to do the same. CLASS cl_alv_grid_handler IMPLEMENTATION.   METHOD handle_toolbar.