SetDelay() in Timer class

hi,
A small doubt ? can we sleep for a while if we are using Timer class .
I used setDelay(1000) method. but it doesn't work like in Thread.sleep(1000). can anybody suggest me.
Thanks ,
-balaji

Assumption: you refer to javax.swing.Timer
Timer timer = new Timer();
timer.start();
...//do stuff
...//blah, blah, blah
//need timer to stop for 2 seconds, give or take
timer.stop();
try{
    Thread.sleep(2000);
}catch(InterruptedException ie){
    ie.printStackTrace();
timer.start();Does that work for you?

Similar Messages

  • Question redarding Timer class

    I have 16 buttons set to disabled initialy. And
    I have a timer event listener which andomly triggers one of 16 buttons to be Enabled every 250ms. How to let this timer object to create a second Timer object
    each time it enables a button. The second timer will have a delay time of 1000ms.
    When it is trggered, the second timer will clear the enabled button to be disabled again.
    It is just like one Enabled button's lift time is 1000ms. And there maybe more than one button lives at same time. How to handle their differnt life time?
    Thank you So much!

    Thank you camickr
    but my program still has problems.
    //Control Button Listener. This starts timer2 which is main timer to andomly
    //pick a button to enable it.
         class ControlButtonListener implements ActionListener{     
              public void actionPerformed(ActionEvent evt){
              System.out.println("Game Start");
              timer2 = new Timer(2000,startPicking);//Main timer     
         timer2.start();
    //Timer2 ActionListener
    class Timer2Listener implements ActionListener{     
         public void actionPerformed(ActionEvent evt){
         int pick = rn.nextInt(16);
              JButton newButton = (JButton) centerPanel.getComponent(pick);
              System.out.println("Picked "+ pick);
              newButton.setIcon(iconNormal);
         centerPanel.getComponent(pick).setEnabled(true);
         int twosec = timern.nextInt(2001);
         System.out.println(twosec);
         timer2.setDelay(twosec);
    //Here is where I create a second timer each time a button was
    //Enabled.
         timer1 = new LifeTimeTimer(1000, stopForOneSec, pick);
         timer1.start();
         timer1.setRepeats(false);
    I also have Extended Timer Class so that timer1 = new LifeTimeTimer(1000, stopForOneSec, pick); can store which button has been enabled.
    and of course Timer1Listener is just for set the enabled button to disabled.
    My problem here is, If there are two buttons are enabled within 1000ms
    That means the first button haven't been disabled, and the second Enabled button
    have already appeared. The second timer(timer1) can only have information about
    the lastest button that just appeared.
    Would you please help me with that?
    I think I missunderstand something. Sorry for bring all the troubles.

  • Formatting incoming string with date/time classes?

    Hello,
    In the software I am writing currently I am @ a certain point talking to an external device. sending requests, receiving responses.
    One of the things I find in the response is "20090429094222", as a string.
    I cannot change anything to that, thats the way I get it from the device, so thats where I'll have to start with.
    As you could probably guess this is a date and a time. Now my question. Is there a good way to format this from 20090429094222
    to
    2009-04-29 09:42:22
    using date and or time classes, not using String operations?
    Thanks in advance.

    I found a class containing 2 functions who do exactly what I need, for those intrested:
    public static Date convertStringToDate(String txtFormat, String txtDate) {
            DateFormat dateFormat = new SimpleDateFormat(txtFormat);
            Date date =  dateFormat.parse(txtDate);
            return date;
    public static String formatDate(Date date, String txtFormat) {
            DateFormat dateFormat = new SimpleDateFormat(txtFormat);
            String txtDate = dateFormat.format(date);
            return txtDate;
        }Using them this way gives me exactly what I want:
    Date dt = DateUtil.convertStringToDate("yyyyMMddHHmmss", incomingDateSTring);
    String newDateString = DateUtil.formatDate(dt, "yyyy-MM-dd HH:mm:ss");Problem solved, thanks alot to those who gave me some explanation on the problem.

  • Timer Class in jsdk 1.4 w2000 doesn't compile

    Since this is based in the tutorial, shouldn't be a big deal but I spent the whole day looking for a solution. Please help!
    The tutorial presents this program:
    //1.3
    import java.util.timer;
    public class Problem {
    public static void main(String[] args) {
    final Timer timer = new Timer();
    timer.schedule(new TimerTask(), 5000);
    System.out.println("In 5 seconds this application will exit. ");
         public class TimerTask implements Timer {
    public void run() {
    System.out.println("Exiting.");
    timer.cancel();
    My problem starts because java.util doesn't have the timer class:
    Problem.java:2: Class java.util.timer not found in import.
    import java.util.timer;
    ^
    Now, JSDK 1.4 doesn't have timer as a package, but as a class, nevertheless, the instruction:
    import java.util.*; // instead of java.util.Timer
    doesn't compile because
    Problem.java:10: Interface Timer of inner class Problem. TimerTask not found.
    Problem.java:6: Class Timer not found in type declaration.
    I think Timer should be expressed as abstract, but how?
    I'm new in Java and feel a little frustrated...

    >
    ProblemSolved.java:3: Class java.util.Timer not found
    in import.
    import java.util.Timer;
    ^
    1 error
    Then you are not using java 1.3. You are using something before that.
    for the Timer and
    javac IteratorDemo.javaIteratorDemo.java:1: Interface java.util.Iterator of
    class IteratorDemo not foun
    d.
    public class IteratorDemo implements
    java.util.Iterator {
    ^
    1 error
    And this suggests that you are using something before 1.2.
    Just a thought...
    Windows comes with the MS version of java, which matches something like 1.1.6. It is in the path. So does you path put the jdk path first or last?

  • Using server time in  Timer Class

    Hai,
    I have develped an application(stand alone) using swings. the exe runs in all the systems in my company.
    requirement is
    --> application has to be closed at 11.59 P.M everyday.
    i did this task using Timer class. Timer class takes the system time in which the application runs. what i need is the server time. so when the application runs it has to check the server time and when the server time is equal to 11.59 PM application has to be closed.
    so how do i map the timer class to my server time?
    iam breaking my head for this for past few days. is there any way to do this?
    thanks

    1)Do you have one database in total? I mean all Java Application read and save data to this database. If so, try to get time from database by using database function. I recommend you to do this because database is central and all application share data with the database.
    2) You can still call web server in Java application. My link in last post will tell you.
    3) You can write a Java Server application for providing current server time for all your Java application. Socket technique may be used.
    Therefore, solution 1 and solution 2 look simpler than solution 3.

  • Timer class and javax.......

    Hi,
    Downloaded the latest java version to d:\download folder. The downloaded file has the name
    " j2re-1.4.2_03-wndows-i586-p.exe ". The file size was about 14.53MB. Double clicking the same installed j2re1.4.2_03 in "C:\Program Files\java\j2re1.4.2_03" folder.
    When I tried to compile Reminder.java program that comes with online Tutorial
    from within C:\Program Files\java\j2re1.4.2_03 at MS-DOS prompt, I got the error message �class java.util.Timer not found in import�.
    I also have Jdk1.1.3 in C:\jdk1.1.3 folder. When I tried to compile Reminder.java from within C:\jdk1.1.3 at MS-DOS prompt, got the same error message,
    Even after changing path variable to C:\jdk1.1.3\bin. Please help.
    Trying to compile any swing program at both DOS prompts gives error message �javax.__________ not found in import�. Can�t figure out why. Please help.
    ammukalai.

    j2re1.4 is a runtime only (ie j2re = Java Runtime Engine) It will not compile java files.
    The timer class was introduced with Java version 1.3.
    You currently have a very old version of 1.1.3.
    You need to download the j2se1.4.2 SDK - http://java.sun.com/j2se/1.4.2/download.html
    The size is closer to 50MB :-)
    Cheers,
    evnafets

  • Need to implement the timer class for 1.1

    Hi
    I am using JDK1.1 for integration with a STB.
    The timer class is not existing for 1.1.
    Where I can find an implementation code of the timer class in order
    to perform a schedule task which work with JDK 1.1
    Thanks
    Fred

    Before you look for Sun's implementation of Timer in post-1.1 versions, make sure you read the licence agreement for those versions and the copyright notice on the code. There's a good chance that by using that code you will be violating one or both of those. This may be a serious issue.
    Your other alternative is to read the API documentation for Timer (and TimerTask) and to write your own implementation. That shouldn't be too difficult.
    I doubt that you will find people actively writing open-source extensions for Java 1.1 since Java 2 has been out for nine years now. Most likely you are on your own there.

  • How to use server time in  Timer Class

    Hai,
    I have develped an application(stand alone) using swings. the exe runs in all the systems in my company.
    requirement is
    --> application has to be closed at 11.59 P.M everyday.
    i did this task using Timer class. Timer class takes the system time in which the application runs. what i need is the server time. so when the application runs it has to check the server time and when the server time is equal to 11.59 PM application has to be closed.
    so how do i map the timer class to my server time?
    iam breaking my head for this for past few days. is there any way to do this?
    thanks

    1)Do you have one database in total? I mean all Java Application read and save data to this database. If so, try to get time from database by using database function. I recommend you to do this because database is central and all application share data with the database.
    2) You can still call web server in Java application. My link in last post will tell you.
    3) You can write a Java Server application for providing current server time for all your Java application. Socket technique may be used.
    Therefore, solution 1 and solution 2 look simpler than solution 3.

  • Timer Class

    Hi
    I am using a timer delay between 2 functions, with the delay of 140ms.  One function triggers an RAW audio file thats embed into the .swf by extending the sound class.
    The problem is, that I am having slight timing issued that seem to be on a global scale.  So far I have to audio channels playing samples that are uncompressed and very short.  I have dicovered and read some adobe cookbooks on the accurateTimer() class, thats been custom built to override the Timer class functions, but I cant seem to get it to work on my set up.
    The app is a music sequencing app that will eventually have 16 channels of audio apposed to the current 2 at present.
    The cookbook is can be found here:
    http://cookbooks.adobe.com/post_Accurate_timer-17332.html
    And my code that drives the audio channels is here:
    var tempo:Number = 125.125;
    var timer:Timer = new Timer(tempo,1);
    timer.addEventListener(TimerEvent.TIMER, switchToColorZero);
    var boxi:int = -1;
    var boxi2:int = -1;
    function changeColours():void
        //trace("changeColours() :" + getTimer());
        ct.color = colour[2];
             if(boxi < boxes.length - 1)
                boxi += 1;
             else
                boxi = 0;
             //if white turn green
             if(boxes[boxi].ONOFF)
                boxes[boxi].transform.colorTransform = ct;
             else
                mix1Transform = new SoundTransform(currVol,currPan);
                mix1 = kick.play();
                mix1.soundTransform = mix1Transform;
                trace(currVol,currPan);
             if(boxi2 < boxes2.length - 1)
                boxi2 += 1;
             else
                boxi2 = 0;
             if(boxes2[boxi2].ONOFF)
                boxes2[boxi2].transform.colorTransform = ct;
             else
                mix2Transform = new SoundTransform(currVol2,currPan2);
                mix2 = hat.play();
                mix2.soundTransform = mix2Transform;
                trace(currVol2,currPan2);
             timer.start();
    function switchToColorZero(e:TimerEvent):void
        //trace("switchToColorZero() :" + getTimer());
            ct.color = colour[0];
            if(boxes[boxi].ONOFF)
                boxes[boxi].transform.colorTransform = ct;
            if(boxes2[boxi2].ONOFF)
                boxes2[boxi2].transform.colorTransform = ct;
            timer.stop();
            timer.reset();
            changeColours();

    What kind of Timer are you writing about..... specify ....
    I know java.util.Timer()
    example with repeats
    java.util.Timer t = new java.util.Timer();
              t.schedule(new java.util.TimerTask() {
                   public void run() {// do something
              }, delay, period);delay - delay in milliseconds before task is to be executed.
    period - time in milliseconds between successive task executions.
    example without repeats
    java.util.Timer t = new java.util.Timer();
              t.schedule(new java.util.TimerTask() {
                   public void run() {// do something
              }, delay);Good Luck

  • Plz help in Timer class

    Plz i want the timer class to start but if a packet was recieved from a client before the time is finished the timer is canceled.
    //e.g
    Datagrampacket rec=new Datagrampacket (byte[],length);
    Timer t=new Timer ();
    t.schedule(MyTimerTask,1000);
    socket.recieve(rec);
    // the timer started and the recieving will not start until the timer stopped.
    //how to make the recieving happen if the timer is still runnig.
    I would be very thankful.

    Starting a timer is asynchroneous, so it will not block. The socket will be able to receive data while the timer is running.
    /Kaj

  • Combining LVOOP DVR with Asynchronous Dynamic Dispatch and Preserve Run-Time Class

    OK, the title sounds like a cornucopia of LVOOP terms.  But there's a reason.  This is in a way an extension of THIS thread.
    What I'm doing recently is creating a LVOOP approach to loading Completely Asynchronous UI elements into subpanels.  This I have combined with a global repository for the objects (which are essentially singletons with a UI functionality) which are shared via DVR, thus eliminating a lot of synchronisation headaches).
    This means that I can ahve a universal framework for launching the UI elements into a subpanel.  The changes made on the Object there are automatically reflected in the global repository.
    So far so good.
    What I don't like too much is a combination of two seemingly awkward code constructs I need in order to keep things running.
    Weird construct 1:
    I have defined a "Launch UI" function in my parent class which is Dynamic Dispatch (Allowing each object to take care of launching its own UI).  This takes a parent object DVR as a second input which I make sure is of the exact same type as the object type being invoked by using the code shown below.  The ACTUAL Type of both inputs to the launch VI within the IPE are identical.  This is guaranteed because I require each new class to override this function.
    Here I pass the DVR from outside the IPE to the "Launch" VI but the Object obtained within the IPE retains information required for DD thus ensuring that the VI called for launching the UI is identical to the ACTUAL object type in the DVR.  This works OK and by placing this weird construct WITHIN the parent class, abuse is minimised, it works fine and seems to have no major side-effects.
    So now we have a VI running asynchronously in the background which belongs to a specific object but has a DVR which it *thinks* is of a Parent Type but, because of the steps taken earlier, is actually of the same type as the object itself.
    In order to make use of the functionality defined in this actual object type, I need to continuously re-interpret the Object within the IPE as shown below.  Otherwise only the Parent functionality is available.
    If I am accessing only methods of the parent class, then the Preserve functionality is not needed.
    Is there a more elegant way to do this?  I find the net result of this code and type-juggling to be really useful and much easier to manage than the non-DVR route since the synchronisation issues disappear.  By making the IPE usage near-atomic we remove the chances of deadlock.
    All editing done in the UI of the asynchronous VI is reflected automatically in any subsequent usage of the DVR.  Even if the DVRs are not shared between VIs, this makes (for me) the headache of synchronisation easier.  If you start expanding this beyond the limits of a single VI, the benefits in Synchronisation become really huge.  You can even have multiple UI objects operating on the same data in the background without extra synchronisation needs.  The only synchronisation required is a global "Data updated" for the object in question whereby the UI elements simply update their indicators and controls from the DVR again.  This is trivial.
    Thus I am convinced that the net result of this is very beneficial.
    My question is if there's a better, safer or more "official" way to do this?
    I was about to start a new Idea for combining the "Preserve Run time Class" and the DVR Terminal of the IPE so that the casting is done automatically.  We could then have a double input to the IPE, the DVR (of base type) plus the ACTUAL Type of the object but of course returning an error if the types are incompatible.  It would be like an "Imposter" DVR input for the IPE which allows a re-interpretation of the object type.
    Would all of this go away if we allowed Dynamic Dispatch to work with DVRs?  Probably.
    Shane
    Say hello to my little friend.
    RFC 2323 FHE-Compliant
    Solved!
    Go to Solution.

    You guys rock!
    I didn't even think of casting the DVR like that.  Kinds stupid of me but I never would have thought it would work.  Cool.
    Also, Yeah, the limitation of no IPE in the Launch VI was one I spotted quite early on.  this is why my Launch VI also doesn't accept more data than is absolutely neccessara because a DVR access in that VI will of course cause a lockup.  I have the system so far now that I can have a SINGLE Launch VI (Which is NOT overridden, so the limitation refers to only a single VI now which is certainly better.
    So again guys, thanks for helping out an old newbie.  I've been around for quite a while, have made many posts but I love the way I just keep learning from others in the Forum.  This is just why I absolutely LOVE it here. 
    Shane.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • Change Timer Class Delay time

    Is it possible to update the Timer Class Delay time while it
    is running. I want to update it using the slider component however
    it doesn't seem to update. I even stop the timer on the THUMB_PRESS
    event of the slider that restart it after it is changed. Doesn't
    seem to work that way either. Any Ideas?

    I figured it out. Instead of setting a variable speed in the
    event handler function for the slider I direclty changed the timer
    delay variable to equal the slider value. I feel dumb now but it
    works great.

  • Forte Timer Class

    From: "GAUR, Anurag" <[email protected]>
    Date: Mon, 17 May 1999 14:03:39 -0400
    Subject: Forte Timer Class
    Hi,
    I'm using Forte's Timer class in developing a Scheduler for our project.
    I have noticed the tick event generated by the Timer class is always late.
    For a timer of 30 minutes duration, the event generated is late by 36
    seconds, for a timer
    of 6 hours duration, its late by 7 minutes and 12 seconds. And for a timer
    of 24 hours
    duration its late by 28 minutes and 49 seconds.
    Any idea why Timer class is behaving like this. Is Timer class notsupposed
    to be
    used for long duration of time ?
    Thanks,
    Anurag GaurAnurag,
    What you have described is consistent with a case I opened last October.
    The case # is 48702- You may want to look it up. Essentially there is a
    defect in the Forte runtime which we observed on Solaris 2.6. Forte on
    Solaris uses the Forte thread package, and the correction for this will go
    very deep. Forte has acknowledged the bug but its probably not going to be
    fixed on version 3. On platforms such as NT native threads are used and
    the problem does not appear. It also doesn't appear on Digital Unix. Our
    workaround is to do time polling in an event loop which works but it's not
    pretty as compared to the Timer.WaitUntil method.
    Good Luck ....
    Charlie Shell
    Information Services, Bell Atlantic Mobile
    2000 Corporate Drive, Orangeburg NY 10962
    E-Mail: [email protected]
    Tel: (914) 365-7927 Cell: (908) 770 -0096
    Pager: 1-800-SKY-8888 pin 6300432
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    What h/w and s/w are you using?
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • Win32 - timer class error

    heres my timer class:
    class Timer
    private:
    UINT_PTR timerid=0;
    unsigned int intInterval=0;
    HWND timerwindow=NULL;
    void TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
    timerprocedure();
    static void CALLBACK _TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime )
    reinterpret_cast<Timer*>(idEvent)->TimerProc(hwnd,uMsg,idEvent,dwTime);
    public:
    std::function<void()> timerprocedure=NULL;
    property<unsigned int> Interval
    Get(unsigned int)
    return intInterval;
    Set(unsigned int uintInterval)
    intInterval = uintInterval;
    if (intInterval==0 && timerid!=0)
    KillTimer(timerwindow,timerid);
    void Start()
    if(timerid!=0)
    KillTimer(timerwindow,timerid);
    timerwindow=GetForegroundWindow();
    timerid=SetTimer( timerwindow,reinterpret_cast<UINT_PTR>(this),(UINT)intInterval,&Timer::_TimerProc);
    SetWindowText(timerwindow,to_string(GetLastError()).c_str());
    void Stop()
    KillTimer(timerwindow,timerid);
    timerid=0;
    ~Timer()
    KillTimer(timerwindow,timerid);
    yesterday was working. and i was seen 1 bug, stoped sometimes when the window loses the focus.
    but now the GetLastError() give 6: invalid handle.
    these don't makes sence to me :(
    is there another timer that don't need the HWND?(for avoid future problems)

    On 2/15/2015 1:29 PM, Cambalinho wrote:
    i had created them on window procedure.
    What is "them"? Created how? What do you mean by "on window procedure".
      and that timer class is another timer. what i mean is the timer
    WM_TIMER and my timer class aren't created
    The only SetTimer call in the code you've shown is the one you admit is failing. To the extent a problem exists, it must be in the code you haven't shown. Lacking mind-reading abilities, I'm afraid I'm unable to assist you any further.
    so maybe the message loop is crazy :(
    Looks OK to me. Well, it may call IsDialogMessage with a NULL handle, but I believe this should cause IsDialogMessage to return FALSE and then the normal message dispatch takes place. Just to be sure, you may want to make it
    [code]
    if (!FormActivated || !IsDialogMessage(FormActivated, &msgEvents))
    [code]
    Igor Tandetnik
    my problem is: no timer is executed :(
     and i don't understand why. only the handle been invalid :(
    see my form\window window procedure:
    void setParent(HWND parent=GetDesktopWindow())
    if (hwnd==NULL)
    WNDCLASSEX FormClass;
    char classname[20]="Form";
    sprintf(classname,"%s",strCaption.c_str());
    HINSTANCE mod = (HINSTANCE)GetModuleHandle(NULL);
    FormClass.cbSize = sizeof(WNDCLASSEX);
    FormClass.style = CS_HREDRAW | CS_VREDRAW;
    FormClass.lpfnWndProc = WndProcForm;
    FormClass.cbClsExtra = 0;
    FormClass.cbWndExtra = 0;
    FormClass.hInstance = mod;
    FormClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    FormClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    FormClass.hbrBackground = (HBRUSH)((COLOR_WINDOW)+1);
    FormClass.lpszMenuName = NULL;
    FormClass.lpszClassName = classname;
    FormClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    // register the new window class
    RegisterClassEx(&FormClass);
    hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, classname, strCaption.c_str(),WS_OVERLAPPEDWINDOW | WS_TABSTOP,
    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, mod, this);
    if (hwnd == NULL)
    MessageBox(NULL, "Can't create the control", "error", MB_OK);
    else
    SetParent(hwnd,parent);
    ShowWindow(hwnd, SW_NORMAL);
    InvalidateRect(hwnd,NULL,true);//i add these line for fix that
    UpdateWindow(hwnd);
    clrBackColor =GetDCBrushColor(GetDC(hwnd));
    clrTextColor = GetTextColor(GetDC(hwnd));
    //window procedure:
    static LRESULT CALLBACK WndProcForm(HWND HandleWindow, UINT msg, WPARAM wParam, LPARAM lParam)
    static POINT PreviousLocation, Location;
    static bool Tracking = false;
    static MouseButtons MBButtons;
    static bool blControl = false;
    static bool blShift = false;
    static bool blResize = false;
    static int KeyDownCount=0;
    static int keyboard[256];
    static int xPos = 0;
    static int yPos = 0;
    static UINT_PTR timerid=0;
    static UINT_PTR KeyBoardTimer=2;
    static UINT_PTR JoystickTimer=1;
    static bool blnDrag = false;
    static bool KeyPressed=false;
    static HMENU menuhandle=NULL;
    HDC hdcimage = CreateCompatibleDC(NULL);
    HBITMAP hbitmap=NULL;
    //UINT JoystickCount =0;
    form *inst = (form *)GetWindowLongPtr(HandleWindow, GWLP_USERDATA);
    if(inst!=NULL && inst->Create!=NULL )
    static bool i=true;
    if(i==true)
    i=false;
    RECT a;
    GetWindowRect(inst ->hwnd,&a);
    inst -> Create(a.left, a.top);
    //Working with messages
    switch(msg)
    case WM_NCCREATE:
    CREATESTRUCT *p = (CREATESTRUCT *)lParam;
    inst = (form *)p->lpCreateParams;
    SetWindowLongPtr(HandleWindow, GWLP_USERDATA, (LONG_PTR)inst);
    inst->hwnd = HandleWindow;
    break;
    case WM_ACTIVATE:
    if (wParam==WA_INACTIVE) // becoming inactive
    FormActivated = NULL;
    else // becoming active
    FormActivated = inst->hwnd;
    return 0;
    break;
    case WM_DRAWITEM:
    DRAWITEMSTRUCT *test=(DRAWITEMSTRUCT*) lParam;
    SendMessage(test->hwndItem, WM_DRAWITEM, wParam, lParam);
    break;
    case WM_USER + 1:
    if(lParam==WM_RBUTTONUP)
    POINT pCursor;
    GetCursorPos(&pCursor);
    HMENU test=GetSubMenu(GetMenu(HandleWindow),0);
    SetForegroundWindow(HandleWindow);
    TrackPopupMenu(test, TPM_LEFTBUTTON | TPM_RIGHTALIGN, pCursor.x, pCursor.y, 0, HandleWindow, NULL);
    PostMessage(HandleWindow, WM_NULL, 0, 0);
    break;
    case WM_ERASEBKGND:
    return DefWindowProc(HandleWindow, msg, wParam, lParam);
    break;
    case WM_CTLCOLORSTATIC:
    return DefWindowProc(HandleWindow, msg, wParam, lParam);
    break;
    case WM_CREATE:
    if(WindowMain == NULL || WindowMain ==GetDesktopWindow())
    WindowMain = HandleWindow;
    SetTimer(inst->hwnd,JoystickTimer,150,NULL);
    SetTimer(inst->hwnd,KeyBoardTimer,150,NULL);
    SendMessage((HWND)lParam , WM_CREATE, wParam, lParam);
    break;
    case WM_SIZE:
    RECT a;
    GetWindowRect(inst->hwnd,&a);
    InvalidateRect(inst->hwnd, &a,true);
    inst->Resize();
    break;
    //for get the menu click event
    //i'm using menu notifications
    case WM_MENUCOMMAND:
    MENUITEMINFO menuInfo;
    menuInfo.cbSize = sizeof(MENUITEMINFO);
    menuInfo.fMask=MIIM_DATA;
    if(GetMenuItemInfo((HMENU)lParam,(UINT) wParam, TRUE, &menuInfo )!=0)
    Menu *mMenu = (Menu *) menuInfo.dwItemData;
    if(mMenu!=NULL)
    mMenu->Click();
    menuhandle=NULL;
    break;
    case WM_TIMER:
    if (wParam == timerid)//for mouse stoped and it's working normaly
    PreviousLocation = Location;
    GetCursorPos(&Location);
    if ((Location.x == PreviousLocation.x) && (Location.y == PreviousLocation.y))
    KillTimer(inst->hwnd, timerid);
    inst->MouseStoped();
    else if(wParam==KeyBoardTimer)
    static bool KeyDown=false;
    static int RepeatKeyDown;
    int key[256];
    GetKeyBoardKeyState(key);
    static int key2[256];
    if(key[AnyKey]==1 && KeyDown==false)
    KeyDown=true;
    RepeatKeyDown++;
    GetKeyBoardKeyState(key2);
    inst->SysKeyDown(key,RepeatKeyDown);
    else if(key[AnyKey]==0 && KeyDown==true)
    KeyDown=false;
    inst->SysKeyUp(key2,RepeatKeyDown);
    RepeatKeyDown=0;
    else if(wParam==JoystickTimer)
    JOYINFOEX b;
    b.dwSize=sizeof(JOYINFOEX );
    b.dwFlags=JOY_RETURNALL;
    //cicle all possible joysticks
    for (int i=0; i<16; i++)
    int direction=0;
    if(joyGetPosEx(i,&b)!= JOYERR_NOERROR) //if theres any error then continue to next joystick
    if(i==0)
    inst->Joystick(-1, -1,-1);
    else
    inst->Joystick(0, -1,-1);
    break;
    long h =b.dwButtons;
    //testing the directions
    //will be 8 directions(inclued diagonals)
    if (b.dwXpos == 0 && b.dwYpos ==65535)
    direction=5;
    else if (b.dwXpos == 65535 && b.dwYpos ==0)
    direction=6;
    else if (b.dwXpos == 65535 && b.dwYpos ==65535)
    direction=7;
    else if(b.dwXpos == 0 && b.dwYpos ==65535)
    direction=8;
    else if (b.dwXpos == 0)
    direction=1;
    else if (b.dwXpos == 65535)
    direction=2;
    else if (b.dwYpos == 0)
    direction=3;
    else if (b.dwYpos == 65535)
    direction=4;
    inst->Joystick(i, direction,h);
    break;
    these don't make sence to me :(

  • Timer class usage!

    from Mr. Mohee Jarada
    Lufthansa Systems - Fort&eacute; Consultant
    Email(s):
    [email protected]
    [email protected]
    Hamburg - Germany
    Hi,
    If any one facing problems with Timer class usage in Forte SO, please read
    the following TechNotes about the solution:
    Technote 11063
    Technote 11548
    Technote 10586
    All the best
    Mohi
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    from Mr. Mohee Jarada
    Lufthansa Systems - Fort&eacute; Consultant
    Email(s):
    [email protected]
    [email protected]
    Hamburg - Germany
    Hi,
    If any one facing problems with Timer class usage in Forte SO, please read
    the following TechNotes about the solution:
    Technote 11063
    Technote 11548
    Technote 10586
    All the best
    Mohi
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

Maybe you are looking for

  • Order Management

    Hi Guys, I am really new to BC and currently trying to better understand the offering to see if it meets my needs. Can you please provide me with some insight based on your experence using BC. I plan to build a order management system where clients c

  • Opening Safari websites with Flash content

    Opening websites with flash content How do I open these types of websites on my IPod Touch Software version 3.0? This is a huge oversight if it cannot be done and a Flash Player App is not available for download. Thanks for any response. Derrell Brow

  • Quicktime plays audio only - QT component needed?

    I received a DVD with a couple of QT files on it (home made). The files are "AVI Movies". Quicktime will play the movie, but it shows black and only plays the audio. Any suggestions on what I need in order to play the QT video with both audio and vid

  • I clicked on a link from my gmail in ipad that looks sketchy. How do I tell if I have been hacked?

    I received an email from "Mail International" with the subject "Ship Notification" indicating that I have a parcel that arrived, and the courier was unable to deliver it. I was actually expecting a package, and it indicated I needed to click on a lin

  • Ipod touch 5g offers/deals

    Are there any offers circling about where if i trade in my ipod touch 3g would i get some sort of special offer or discount on the ipod touch 5g