cambalinho 142 Practically a Posting Shark

anotherthing: when i do from string to char: i get an error: 'cast from 'const char*' to 'char' loses precision [-fpermissive]|'
what you can advice?

TableMenuShortCuts[TableMenuShortCuts.size()-1].key=(char)j.c_str();

key structure member is char and the j is the string

cambalinho 142 Practically a Posting Shark

i did these function for uppercase:

string Upper(string text)
{
    string result;
    result.resize(text.size());
    for(int i=0; i<text.size(); i++)
    {
        if(text[i]>96 && text[i]<123)
            result[i]= text[i]-32;
        result[i]=text[i];
    }
    return result;
}

but i'm getting the wrong results :(
what i'm doing wrong?

cambalinho 142 Practically a Posting Shark

using the WM_KEYUP, can i see if the shift\control\alt keys was uped too?

cambalinho 142 Practically a Posting Shark

ok. for use menu shorcuts i must create a table accelerator and change my message loop. but can i process the table accelerator without use the HWND?

cambalinho 142 Practically a Posting Shark

finally i correct that:

//when the mouse move, enter, leave and leave the menu
                case WM_MENUSELECT:
                {
                    static int Last_Menu_ID = -1;
                    if(((HIWORD(wParam) & MF_HILITE) || (HIWORD(wParam) & MF_MOUSESELECT)) && GetMenuState((HMENU)lParam,LOWORD(wParam),MF_BYCOMMAND)!=0xFFFFFFFF)
                    {
                        //mouse leave the previous menu item
                        if(GetMenuState((HMENU)lParam,Last_Menu_ID,MF_BYCOMMAND)!=0xFFFFFFFF)
                        {
                            MENUITEMINFO menuInfo;
                            menuInfo.cbSize = sizeof(MENUITEMINFO);
                            menuInfo.fMask=MIIM_DATA;
                            GetMenuItemInfo((HMENU)lParam,Last_Menu_ID, FALSE, &menuInfo );
                            Menu *mMenu = (Menu *) menuInfo.dwItemData;
                            if (mMenu!=NULL)
                            {
                                mMenu->Leave();
                            }
                        }
                        //Mouse Enter on actual menu item
                        MENUITEMINFO menuInfo1;
                        menuInfo1.cbSize = sizeof(MENUITEMINFO);
                        menuInfo1.fMask=MIIM_DATA;
                        GetMenuItemInfo((HMENU)lParam,LOWORD(wParam), FALSE, &menuInfo1 );
                        Menu *mMenu = (Menu *) menuInfo1.dwItemData;
                        if (mMenu!=NULL)
                        {
                            mMenu->Enter();
                        }
                        Last_Menu_ID = LOWORD(wParam);
                    }
                    //testing if the menu item is valid and the Last_Menu_ID isn't -1
                    else if(GetMenuState((HMENU)lParam,LOWORD(wParam),MF_BYCOMMAND)==0xFFFFFFFF && Last_Menu_ID != -1 )
                    {
                        //mouse live the menu
                        MENUITEMINFO menuInfo;
                        menuInfo.cbSize = sizeof(MENUITEMINFO);
                        menuInfo.fMask=MIIM_DATA;
                        GetMenuItemInfo(menuhandle,Last_Menu_ID, FALSE, &menuInfo );
                        Menu *mMenu = (Menu *) menuInfo.dwItemData;
                        if (mMenu!=NULL)
                        {
                            mMenu->Leave();
                        }
                        Last_Menu_ID = -1;
                    }
                    return DefWindowProc(HandleWindow, msg, wParam, lParam);
                }
                break;

thanks for all

cambalinho 142 Practically a Posting Shark

i think that i miss undertood your code:

case WM_MENUSELECT:
                {
                    static int Last_Menu_ID = -1;
                    if(((HIWORD(wParam) & MF_HILITE) || (HIWORD(wParam) & MF_MOUSESELECT)) && GetMenuState(menuhandle,LOWORD(wParam),MF_BYCOMMAND)!=-1)
                    {
                        //Mouse Enter
                        Last_Menu_ID = LOWORD(wParam);
                        MENUITEMINFO menuInfo;
                        menuInfo.cbSize = sizeof(MENUITEMINFO);
                        menuInfo.fMask=MIIM_DATA;
                        GetMenuItemInfo((HMENU)lParam,Last_Menu_ID, FALSE, &menuInfo );
                        Menu *mMenu = (Menu *) menuInfo.dwItemData;
                        if (mMenu!=NULL)
                        {
                            mMenu->Enter();
                        }
                    }
                    else if(HIWORD(wParam) == 0xFFFF && lParam == 0x0000)
                    {
                        //mouse live the menu
                        if(Last_Menu_ID != -1)
                        {
                            MENUITEMINFO menuInfo;
                            menuInfo.cbSize = sizeof(MENUITEMINFO);
                            menuInfo.fMask=MIIM_DATA;
                            GetMenuItemInfo((HMENU)lParam,Last_Menu_ID, FALSE, &menuInfo );
                            Menu *mMenu = (Menu *) menuInfo.dwItemData;
                            if (mMenu!=NULL)
                            {
                                mMenu->Leave();
                            }
                            Last_Menu_ID = -1;
                        }
                        else
                        {
                            Last_Menu_ID = -1;
                            SetWindowText(HandleWindow,"ALL Menus Closed");
                        }
                    }
                    else
                    {
                        //mouse leave the menu item
                        if(Last_Menu_ID != -1) 
                        {
                            MENUITEMINFO menuInfo;
                            menuInfo.cbSize = sizeof(MENUITEMINFO);
                            menuInfo.fMask=MIIM_DATA;
                            GetMenuItemInfo((HMENU)lParam,Last_Menu_ID, FALSE, &menuInfo );
                            Menu *mMenu = (Menu *) menuInfo.dwItemData;
                            if (mMenu!=NULL)
                            {
                                mMenu->Leave();
                            }
                            Last_Menu_ID = -1;
                            //SetWindowText(HandleWindow, to_string(GetLastError()).c_str());
                        }
                    }
                    return DefWindowProc(HandleWindow, msg, wParam, lParam);
                }
                break;

the mouse leave(menu item) isn't working :(

cambalinho 142 Practically a Posting Shark

now i'm trying do the mouse enter and mouse exit commands:

case WM_MENUSELECT:
                {
                    if(menuitem!=-1)//call the mouse exit
                    {
                        MENUITEMINFO menuInfo;
                        menuInfo.cbSize = sizeof(MENUITEMINFO);
                        menuInfo.fMask=MIIM_DATA;

                        GetMenuItemInfo((HMENU)lParam,menuitem, FALSE, &menuInfo );

                        Menu *mMenu = (Menu *) menuInfo.dwItemData;
                        if (mMenu!=NULL)
                        {
                            mMenu->Leave();
                        }
                    }
                    //do the mouse enter
                    menuitem=LOWORD(wParam);
                    MENUITEMINFO menuInfo;
                    menuInfo.cbSize = sizeof(MENUITEMINFO);
                    menuInfo.fMask=MIIM_DATA;

                    GetMenuItemInfo((HMENU)lParam,menuitem, FALSE, &menuInfo );

                    Menu *mMenu = (Menu *) menuInfo.dwItemData;
                    if (mMenu!=NULL)
                    {
                        mMenu->Enter();
                    }

                    return 0;
                }
                break;

but don't works :(
(after a menu item been clicked, the menuitem will be -1)
so what i'm doing wrong?

cambalinho 142 Practically a Posting Shark

thanks for that you give me an idea ;)

case WM_SYSCOMMAND:
                {
                    if (menuhandle!=NULL && GetMenuState(menuhandle,wParam,MF_BYCOMMAND)!=-1 )
                    {
                        MENUITEMINFO menuInfo;
                        menuInfo.cbSize = sizeof(MENUITEMINFO);
                        menuInfo.fMask=MIIM_DATA;

                        GetMenuItemInfo(menuhandle,(UINT) wParam, FALSE, &menuInfo );

                        Menu *mMenu = (Menu *) menuInfo.dwItemData;
                        if (mMenu!=NULL)
                        {
                            mMenu->Click();
                        }
                    }
                    menuhandle=NULL;
                    menuitem=-1;

                    return DefWindowProc(HandleWindow, msg, wParam, lParam);
                }
                break;

i will test more, but i think it's working fine... thanks
thanks for your sample ;)

cambalinho 142 Practically a Posting Shark

thanks your code is nice and i understand it ;)
let me ask 1 thing: using WM_SYSCOMMAND what is the wParam that tell me that the any menu was clicked?
unless i take off all the wParam consts for do the job ;)
i see the wParam or is a menu ID or a system action

cambalinho 142 Practically a Posting Shark

the system control menu, uses the WM_SYSCOMMAND message. the WM_MENUSELECT and WM_INITMENUPOPUP messages are global i think.
using the WM_SYSCOMMAND and return:

return DefWindowProc(HandleWindow, msg, wParam, lParam);

if i open the control menu and then close it(without click on menu item, just out of the menu), the windows(OS) can give me an error and then close my program :(

cambalinho 142 Practically a Posting Shark

continue with WM_SYSCOMMAND: how can i test if the menu item was clicked?
(if i open an close the control system menu(without click on menu item), i will get errors)

cambalinho 142 Practically a Posting Shark

the wParam, on WM_SYSCOMMAND, give me the menu item ID ;)
thanks for all

cambalinho 142 Practically a Posting Shark

i'm trying several ways without sucess :(

case WM_INITMENUPOPUP:
                {
                    menuhandle=(HMENU)wParam;
                    return 0;
                }
                break;

                case WM_SYSCOMMAND:
                {
                    if(wParam & SC_MOUSEMENU)
                    {
                        MENUITEMINFO menuInfo;
                        menuInfo.cbSize = sizeof(MENUITEMINFO);
                        menuInfo.fMask=MIIM_DATA;
                        int xPos = GET_X_LPARAM(lParam);    // horizontal position
                        int yPos = GET_Y_LPARAM(lParam);    // vertical position
                        menuposition=MenuItemFromPoint(HandleWindow,menuhandle,{xPos,yPos});
                        if(!GetMenuItemInfo(menuhandle,(UINT) menuposition, true, &menuInfo ))
                        {
                            Menu *mMenu = (Menu *) menuInfo.dwItemData;
                            if (mMenu!=NULL)
                            {
                                mMenu->MenuClick();
                            }
                        }
                    }

                    return 0;
                }
                break;

now the control system menu isn't showed when i click on it :(

cambalinho 142 Practically a Posting Shark

i'm using the HiliteMenuItem() for test if the mouse is above the menu item:

int i=0;
                        for(i=0; i<GetMenuItemCount(menuhandle); i++)
                        {
                            if(HiliteMenuItem(HandleWindow,menuhandle,i,MF_BYPOSITION) == true)
                            {
                                menuposition=(UINT)i;
                                break;
                            }
                        }

but i always get the number 0. heres how i detect the menu handle:

case WM_INITMENUPOPUP:
                {
                    menuhandle=(HMENU)wParam;
                    return 0;
                }
                break;

what i'm doing wrong?

cambalinho 142 Practically a Posting Shark

the download always stoped. now i formated the pc and works fine.
thanks for all

cambalinho 142 Practically a Posting Shark

i'm haviing problems with my windows 7. i do some downloads and they stop before been finished :(
even the microsoft essencials isn't updated :(
what is going on with my OS? what isn't right?

cambalinho 142 Practically a Posting Shark

see these code too:

 Set(string text)
        {
            char d[255];
            MENUITEMINFO  s;
            s.cbSize=sizeof(MENUITEMINFO );
            s.fMask=MIIM_STRING;
            s.dwTypeData=(LPSTR)text.c_str();
            if(primeiromenu==true)//these menu handle is tested
            {
               SetMenuItemInfo (mnuBar,GetMenuPosition(mnuBar,strCaption), true, &s);
            }
            else if(ispopup==true)
                SetMenuItemInfo (MenuPopup,GetMenuPosition(MenuPopup,strCaption), true, &s);
            else
                SetMenuItemInfo (MenuHandle,ID, false, &s);
            DrawMenuBar(Mainwindow);
            strCaption=text;
        }

(primeiro -> first)

cambalinho 142 Practically a Posting Shark
int GetMenuPosition(HMENU menu, string caption)
    {
        int i=0;
        for(i=0; i<GetMenuItemCount(menu)-1;i++)
        {
            MENUITEMINFO  s= {0};
            s.cbSize=sizeof(MENUITEMINFO );
            s.fMask=MIIM_STRING;
            s.cch=strlen(strCaption.c_str());
            GetMenuItemInfo (menu,i, true, &s);

            if(caption == s.dwTypeData)
                 break;
        }
        MessageBox(NULL,to_string(i).c_str(),"menuposition", MB_OK);
        return i;
    }

a memory error.
'the program stops responding' and the OS closes the program

cambalinho 142 Practically a Posting Shark

i did 1 code for give me the menu position. but i'm getting problems compare the LPSTR or LPCSTR with string :(

int GetMenuPosition(HMENU menu, string caption)
    {
        int i=0;
        for(i=0; i<GetMenuItemCount(menu)-1;i++)
        {
            MENUITEMINFO  s= {0};
            s.cbSize=sizeof(MENUITEMINFO );
            s.fMask=MIIM_STRING;
            s.cch=strlen(strCaption.c_str());
            //s.dwTypeData=(LPSTR)strCaption.c_str();
            GetMenuItemInfo (menu,i, true, &s);
            string b=static_cast<char*>(s.dwTypeData);

            if(b==caption)
                 break;
        }
        MessageBox(NULL,to_string(i).c_str(),"menuposition", MB_OK);
        return i;
    }

can anyone explain to me?

cambalinho 142 Practically a Posting Shark

sorry i continue with problems(thats why i came up with another idea) :(
i did in these way:

//when i create the menu item:
 //put the this on dwItemData
 MENUITEMINFO  s;
 GetMenuItemInfo (hMenu,intID, true, &s);
 s.cbSize=sizeof(MENUITEMINFO );
 s.fMask=MIIM_DATA;
 s.dwItemData=(ULONG_PTR)this;
 SetMenuItemInfo (hMenu,intID, true, &s);

//change the menu for use the WM_MENUCOMMAND
MENUINFO mnInfo;
GetMenuInfo(hMenu,&mnInfo);
mnInfo.cbSize=sizeof(MENUINFO);
mnInfo.fMask=MIM_STYLE;
mnInfo.dwStyle=MNS_NOTIFYBYPOS;
SetMenuInfo(hMenu,&mnInfo);

and with WM_MENUCOMMAND in main window:

case WM_MENUCOMMAND:
{
BOOL fResult = FALSE;
MENUITEMINFO menuInfo = { 0 };

menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_ID | MIIM_DATA;

fResult = GetMenuItemInfo((HMENU)lParam,(UINT) wParam, TRUE, &menuInfo );

if (fResult!=0)
{
UINT myId = menuInfo.wID; // this is item ID
ULONG_PTR myData = menuInfo.dwItemData; // item data (like 'this' pointer')
CREATESTRUCT *p = (CREATESTRUCT *)(ULONG_PTR)(menuInfo.dwItemData);
Menu *mMenu = (Menu*)p->lpCreateParams;
//if(mMenu->MenuClick==NULL) break;
mMenu->MenuClick();//it's a lambda function variable
}                    
}

but i don't get the 'this' pointer correctly, why?

cambalinho 142 Practically a Posting Shark

finally i did it:

void AccaoDoRato(int x, int y, HWND Destino, int Butao=0)
{
    //get the actual window
    HWND JanelaActual = GetForegroundWindow();

    //get the position mouse
    POINT PosicaoCursor;
    GetCursorPos(&PosicaoCursor);
    Sleep(1000);

    //change mouse position
    POINT CursorNovaPosicao;
    CursorNovaPosicao.x=x;
    CursorNovaPosicao.y=y;
    ClientToScreen(Destino,&CursorNovaPosicao);
    SetCursorPos(CursorNovaPosicao.x,CursorNovaPosicao.y);

    //send the message mouse... seems that i must use the 2(up and down)
    INPUT Input={0};
    // left down
    Input.type = INPUT_MOUSE;
    if(Butao==ButaoEsquerdo)
        Input.mi.dwFlags  = MOUSEEVENTF_LEFTDOWN;
    else if(Butao==ButaoDireito)
        Input.mi.dwFlags  = MOUSEEVENTF_RIGHTDOWN;
    else if(Butao==ButaoDireito)
        Input.mi.dwFlags  = MOUSEEVENTF_MIDDLEDOWN;
    SendInput(1,&Input,sizeof(INPUT));

    // left up
    ZeroMemory(&Input,sizeof(INPUT));
    Input.type = INPUT_MOUSE;
    if(Butao==ButaoEsquerdo)
        Input.mi.dwFlags  = MOUSEEVENTF_LEFTUP;
    else if(Butao==ButaoDireito)
        Input.mi.dwFlags  = MOUSEEVENTF_RIGHTUP;
    else if(Butao==ButaoDireito)
        Input.mi.dwFlags  = MOUSEEVENTF_MIDDLEUP;
    SendInput(1,&Input,sizeof(INPUT));
    Sleep(1000);

    //back to the used window
    SetFocus(JanelaActual);

    //back to the mouse position
    SetCursorPos(PosicaoCursor.x,PosicaoCursor.y);
}

thansk for all

cambalinho 142 Practically a Posting Shark

i know move the mouse for where i want. but how can send a click message to another program?

cambalinho 142 Practically a Posting Shark

nullptr so how can i send the message?

cambalinho 142 Practically a Posting Shark

triumphost: sorry about that. it's my own property class with 2 macros ;)
i'm using C/C++11 with Code Blocks.

i resolve the problem. the popup menu is showed ;)

void Show(HWND mainshowed)
    {
        POINT  p;
        GetCursorPos(&p);
        SetForegroundWindow(mainshowed);
        TrackPopupMenu(MenuHandle,NULL,p.x,p.y,0,mainshowed,NULL);
        PostMessage(mainshowed, WM_NULL, 0, 0);
    }

but i have some problems for subclassing the procedure messages :(

Menu(string caption="&Menu",HMENU subtmenu=NULL, HWND MainHWND=WindowMain)
    {
        intID=intID+1;
        ID=intID;
        if(caption!="-")
            caption=(string)caption + " " + to_string(ID);
        strCaption=caption;
        if(GetMenu(MainHWND)==NULL)
            hMenu = CreateMenu();
        else
            hMenu =GetMenu(MainHWND);
        if (subtmenu==NULL)
        {
            HMENU hSubMenu=CreatePopupMenu() ;
            AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, caption.c_str());
            MenuHandle=hSubMenu;//my error was here
            SetMenu(MainHWND, hMenu);
            menuposition=GetMenuItemCount(hMenu)-1;
            primeiromenu=true;
        }
        else
        {
            if(caption=="-")
                AppendMenu(subtmenu, MF_SEPARATOR, ID, caption.c_str());
            else
                AppendMenu(subtmenu, MF_STRING, ID, caption.c_str());
            MenuHandle=subtmenu;
            menuposition=GetMenuItemCount(subtmenu)-1;
            SetMenu(MainHWND, hMenu);
        }

        SetWindowLong(MainHWND,GWL_WNDPROC,(LONG)MenuSubclassProc);
        SetWindowLong(MainHWND,GWL_USERDATA,(LONG)this);

    }
    //the MainHWND is the form handle. in these case i think is wrong, 
    //but i don't know get the menu HWND from HMENU :(

    //the message procedure:
    static LRESULT CALLBACK MenuSubclassProc( HWND hwnd, UINT uMsg, WPARAM wParam,  LPARAM lParam)
    {
       Menu *wnd = 0;

        // retrieve associated Window instance
        wnd = reinterpret_cast<Menu *>(GetWindowLong(hwnd, GWL_USERDATA));
        if(uMsg==WM_COMMAND)
            wnd->MenuClick();//the MenuClick it's a lambda variable
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

and in form window procedure message i have:

case WM_COMMAND:
                {
                    //inst->MenuClick((int)wParam) ;

                    SendMessage((HWND)lParam , WM_COMMAND, wParam, lParam);
                }
                break;

advice me more.

cambalinho 142 Practically a Posting Shark

i did these menu class:

class Menu
{
private:
    static int intID;
    int ID=0;
    bool primeiromenu=false;
    HMENU MenuHandle=NULL;
    HMENU hMenu=NULL;
    int menuposition=0;
    string strCaption="";
    public:
    Menu(string caption="&Menu",HMENU subtmenu=NULL, HWND MainHWND=WindowMain)
    {
        intID=intID+1;
        ID=intID;
        if(caption!="-")
            caption=(string)caption + " " + to_string(ID);
        strCaption=caption;
        if(GetMenu(MainHWND)==NULL)
            hMenu = CreateMenu();
        else
            hMenu =GetMenu(MainHWND);
        if (subtmenu==NULL)
        {
            HMENU hSubMenu=CreatePopupMenu() ;
            AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, caption.c_str());
            MenuHandle=hSubMenu;//my error was here
            SetMenu(MainHWND, hMenu);
            menuposition=GetMenuItemCount(hMenu)-1;
            primeiromenu=true;
        }
        else
        {
            if(caption=="-")
                AppendMenu(subtmenu, MF_SEPARATOR, ID, caption.c_str());
            else
                AppendMenu(subtmenu, MF_STRING, ID, caption.c_str());
            MenuHandle=subtmenu;
            menuposition=GetMenuItemCount(subtmenu)-1;
            SetMenu(MainHWND, hMenu);
        }
    }

    void Show(HWND mainshowed)
    {
        LPPOINT x;
        GetCursorPos(x);
        SetForegroundWindow(mainshowed);
        TrackPopupMenu(MenuHandle,NULL,x->x,x->y,0,mainshowed,NULL);
        PostMessage(mainshowed, WM_NULL, 0, 0);
    }

    int getmenuposition()
    {
        return menuposition;
    }

    property<string> Caption
    {
        Get(string)
        {
            return strCaption;

        },
        Set(string text)
        {
            MENUITEMINFO mi;
            mi.cbSize=sizeof(MENUITEMINFO);
            if(primeiromenu==true)
                GetMenuItemInfo(GetMenu(WindowMain),menuposition,true,&mi);
            else
                GetMenuItemInfo(MenuHandle,menuposition,true,&mi);
            mi.fMask=MIIM_STRING;
            mi.dwTypeData =(LPTSTR)text.c_str();
            if(primeiromenu==true)
                SetMenuItemInfo(GetMenu(WindowMain),menuposition,true,&mi);
            else
                SetMenuItemInfo(MenuHandle,menuposition,true,&mi);

        }
    };

    operator int()
    {
        return ID;
    }

    operator HMENU()
    {
        return MenuHandle;
    }
    void Destroy()
    {
        DestroyMenu(MenuHandle);
    }
};
int Menu::intID=0;

the function Show only show me the menu rectangle... and the OS close the program. what i'm doing wrong?

cambalinho 142 Practically a Posting Shark

Schol-R-LEA yes;)
my property class works fine. but i only need change the Get() macro nothing more ;)

cambalinho 142 Practically a Posting Shark

NathanOliver: in these case must be a macro... at leastt i think ;)
see these propertie sample:

 property <int> Mousehover
        {
            Get(int)
            {
               return intMouseHover;
            },
            Set(int mousehover)
            {
                intMouseHover = mousehover;
            }
        };

like you see the 'int', on 'Get', is like an argument and not like return... but the macro make it like a return value :(
so how can i change that macro for work like a normal function?

cambalinho 142 Practically a Posting Shark

i'm sorry AndrisP... i'm sorry my english. but i'm trying :(
my actual macro is:

#define Get(x) [this]()->x

the 'x' is the type. but the Get() returns a 'x' value. so the 'x' must be on back of the Get()(like another functions). but i don't know change that with macros :(

cambalinho 142 Practically a Posting Shark

sorry not that. the 'x' is the type

cambalinho 142 Practically a Posting Shark

i did the Get macro and works fine:

#define Get(x) [this]()->x

(like you see it's a lambda function header)
but i see 1 problem(sample):

Get(int)

like you see the type is inside of the macro function :(
but i need it:

int Get()

can anyone advice me for do these change?
i use c++ 11

cambalinho 142 Practically a Posting Shark

gerbil: i did more things: scandisk, and sfc /sannow command line. the scannow found 1 error. and they did more updates and now the gif's are showed normaly ;)
thanks for all to all

cambalinho 142 Practically a Posting Shark

some gifs file aren't showed because of my network and not the page.
and sometimes are showed. i'm confused on these :(
please i accept more information

cambalinho 142 Practically a Posting Shark

the chrome seems, sometimes, not activate it :(
but i did the sfc /scannow by prompth(like DOS) and found 1 error and i used the scdk with prompth too ;)
now i have some problems resolved. but i must format the laptop. thanks for all to all

cambalinho 142 Practically a Posting Shark

i have the last update of java, but i'm getting some problems with it :(
sometimes works other times don't. only in internet explorer works more or less but not on chrome.
can anyone explian to me how can i fix the problem?

cambalinho 142 Practically a Posting Shark

by several reasons, i must create the static with it's paint message:

case WM_PAINT:
            {
                PAINTSTRUCT  ps;
                HDC hdc = BeginPaint(inst->hwnd, &ps);
                if(inst->Paint==NULL)
                {
                    RECT f;
                    GetClientRect(hwnd,&f);
                    HBRUSH s=CreateSolidBrush(inst->clrBackColor);
                    SelectObject(hdc,(HBRUSH)s);
                    if (inst->clrBackColor==-1)
                    {
                        //hide, copy the parent control and show the control again
                        ShowWindow(inst->hwnd,SW_HIDE);
                        BitBlt(hdc,0,0,f.right-f.left,f.bottom-f.top,GetDC(GetParent(inst->hwnd)),inst->intLeft,inst->intTop,SRCCOPY);
                        ShowWindow(inst->hwnd,SW_SHOW);
                    }
                    else
                        FillRect(hdc,&f,s);
                    SetBkMode(hdc,TRANSPARENT);
                    char *text=(char*)inst->strCaption.c_str();
                    SetTextColor(hdc,inst->clrTextColor );
                    DrawTextEx(hdc,text,-1,&f,DT_CENTER,NULL);
                    DeleteObject(s);
                }
                else
                    inst->Paint(inst->hwnd,hdc);
                EndPaint(inst->hwnd, &ps);
            }
            break;

i can't use the WS_EX_TRANSPARENT style, because when i call the InvalidateRect()(and the parent have the WS_CLIPCHILDREN style), the static control is never showed. so i did it using the WM_PAINT message.
but when it's transparent i can't copy tthe parent HDC with BitBlt() :(
what i'm doing wrong?
(it's called a false transparent)

cambalinho 142 Practically a Posting Shark

from reading these site: http://www.catch22.net/tuts/flicker-free-drawing
i understand that i must avoid the pixel been changed more than once and a double-buffer:

//how avoid the pixel be changed more than once:
case WM_ERASEBKGND:
    return 1;

//for other controls, we must use another messsage(see the child control messages)

and heres how we do a double buffer:

HDC          hdcMem;
HBITMAP      hbmMem;
HANDLE       hOld;

PAINTSTRUCT  ps;
HDC          hdc;

hdc = BeginPaint(hwnd, &ps);
//if we use another message instead the WM_PAINT, we use the GetDC() function
//for get the HDC

    // Create an off-screen DC for double-buffering
    hdcMem = CreateCompatibleDC(hdc);//here we can use NULL too
    hbmMem = CreateBitmap(win_width, win_height,1,32,NULL);
    //that site use the CreateCompatibleBitmap() function, but use my line for get
    //the correct results ;)

    //select the new bitmap to hdcMem
    hOld   = SelectObject(hdcMem, hbmMem);
    //the hOld is for get the original bimap.. good for restore the old image

    // Draw into hdcMem here

    // Transfer the off-screen DC to the screen
    BitBlt(hdc, 0, 0, win_width, win_height, hdcMem, 0, 0, SRCCOPY);

    // Free-up the off-screen DC
    SelectObject(hdcMem, hOld);
    DeleteObject(hbmMem);
    DeleteDC    (hdcMem);

doing these the image never more flicker... and it's great because we draw it just once ;)
anotherthing: please create the DC and delete it ouside the WM_PAINT message for avoid flicker too.
the form show us the image correctly. but the child controls continue flickering :(
can anyone advice me more?
i know about the WS_CLIPCHILDREN style(it's only for the form), but …

cambalinho 142 Practically a Posting Shark

i continue with problems for use a callback function in a class member :(

class Timer
{
    private:
        typedef std::function<void(void)> timerprocedure;
        timerprocedure tmrprocedure;//can't be static
        int MilliSecondsTimer;
        bool blnDestroyed;
        UINT TimerId;
        HANDLE Timer1;
        static void CALLBACK MyTimerProc( HWND hwnd,  UINT message, UINT idTimer,  DWORD dwTime)
        {
            tmrprocedure();//call the lambda timer function
            //error: "invalid use of member 'Timer::tmrprocedure' in static member function"
        }
    public:

        int SetMilliSeconds(int MilliSeconds)
        {
            MilliSecondsTimer = MilliSeconds;
            return 0;
        }

        int GetMilliSeconds()
        {
            return (MilliSecondsTimer);
        }

        int Start(timerprocedure TimerProc)//receives the lambda timer function
        {

            tmrprocedure=TimerProc;
            TimerId = SetTimer(0, 0, MilliSecondsTimer,MyTimerProc);//activate the timer with timer callback procedure
            if(TimerId==NULL)
                MessageBox(NULL,"error","error",MB_OK);
            return 0;
        }

        int Stop()
        {
            KillTimer( 0,TimerId);
            return 0;
        }

        ~Timer()
        {
            Stop();
        }
};

the tmrprocedure needs to be static, but i don't want it static... so how can i pass the this class pointer with SetTimer() and how can i get the pointer in MyTimerProc() callback?

cambalinho 142 Practically a Posting Shark

i'm very confused and the others forums make me more confused :(
i'm using string, so i need convert string to WCHAR*:

const size_t len = filename.length() + 1;
            wchar_t wcstring[len];
            swprintf(wcstring, len, L"%s", filename.c_str());

            Gdiplus::Image img2(wcstring);

the img2 read the file normaly, but i'm creating another Image variable in class private section:

class image
{
private:
    ULONG_PTR m_gdiplusToken;
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    HDC hdcimage=CreateCompatibleDC(NULL);
    Gdiplus::Graphics graphics;
    Gdiplus::Image img;
    ///................

but for work in image constructors i must do(or i get several errors):

public:
    image() : graphics(hdcimage),img((WCHAR*)(L"C:\\"))
    {
    //..................

but for string:

image(  const string & filename)  : graphics(hdcimage),img(towstring(filename))
    {
    //.............

i'm getting errors:
"call of overloaded 'Image(wchar_t)' is ambiguous"
why?? see my function:

wchar_t towstring(const std::string& s)
{
    wchar_t Wstring;
    int c =  MultiByteToWideChar( CP_UTF8 , 0 , s.c_str() , s.size() , &Wstring, 0 );
    return Wstring;
}

i'm confused from information that gevi me :(
so what is 'WCHAR'? how can i convert it to string?
i'm sorry, but i'm several confused with these :(

cambalinho 142 Practically a Posting Shark

thanks for all

cambalinho 142 Practically a Posting Shark

sorry let me ask 1 thing:
if i can do these(on construtor):

classname(std::function<void(...)> func)

why i can't do these?

std::function<void(...)> Event; //like you see is like creating a variable
cambalinho 142 Practically a Posting Shark

ok.. but why that error message?
seems that i can't use lambdas with auto

cambalinho 142 Practically a Posting Shark

seems that my best thing still be the pre-compiler way:

#define event(eventname, ... ) std::function<void(__VA_ARGS__ )> eventname

sample:

event(Move, (int x, int y)) = [](int x, int y) {;};
event(Visible) = []() {;};

but like we know the #define use it like a functions... but i wanted something like these:

event Move(int x, int y) = [](int x, int y) {;};
event Visible = []() {;};
cambalinho 142 Practically a Posting Shark

and i get these error with your sample:
"non-static data member declared 'auto'"

cambalinho 142 Practically a Posting Shark

thanks for that my friend.
let me ask 1 thing: why i can't change the 'auto' keyword with typedef?

typedef auto Event;

error message:
"typedef declared 'auto'"
if the 'auto' is like a type, why i can't chnage the name?

cambalinho 142 Practically a Posting Shark

yah.. i even can't use the boost library :)
thanks for all... maybe i can 'install' the CImg on pc ;)
thanks for all

cambalinho 142 Practically a Posting Shark

so how can i read some images files with C\C++ using IDE diferent from Visual Studio?

cambalinho 142 Practically a Posting Shark

how can i build a typedef with variadic operator?
what i mean is that i need build these:

typedef std::function<void(void)> Event;//works fine, but for any parameters



typedef std::function<void(...)> Event; //no errors



Event test(int x, int y)=[](int x, int y)
        {
            int a=x+y;
            string b=tostring(a);
            MessageBox(NULL,b.c_str(),"hello",MB_OK);
        };

in these sample i get 1 error:

"invalid pure specifier (only '= 0' is allowed) before ']' token"
how can i fix the error?

cambalinho 142 Practically a Posting Shark

i'm buiding an image class, but i need some information...
the C\C++ teach how read binary\text files... but not how the files are build like JPEG, PNG, GIF and others :(
i can't find a page for give me the file struture and when i found it, i only see hexadecimal values and it's confused for me :(
can anyone advice me?

cambalinho 142 Practically a Posting Shark

sorry but i'm confused with 1 thing:my brother have 1 joystick more or less like that layout. but the hat control and the X,Y do the same actions... is these normal or fix or i can change the X,Y axis?

cambalinho 142 Practically a Posting Shark

i'm trying to understand some joystick structure: http://msdn.microsoft.com/en-us/library/windows/desktop/dd757112%28v=vs.85%29.aspx
but isn't easy. at least these image help me more(joystick layout):
https://onedrive.live.com/?cid=C3EF456E15C8DEB6&id=C3EF456E15C8DEB6!1259&v=3

but i need ask more:
1 - the Hat and X and Y coordenates are the same or they can be programmed in separed ways?
2 - i can't find the POV, U, V, R buttons\coordenates\axis... can anyone help me on these?