156 Archived Topics
Remove Filter i have these function for create the tooltip: HWND CreateToolTip(HWND hwndTool, string text) { /*INITCOMMONCONTROLSEX icc; icc.dwSize = sizeof(INITCOMMONCONTROLSEX); icc.dwICC = ICC_BAR_CLASSES | ICC_TAB_CLASSES | ICC_WIN95_CLASSES; InitCommonControlsEx(&icc);*/ if (text=="") { return FALSE; } // Get the window of the tool. //HWND hwndTool = GetDlgItem(hDlg, toolID); // Create the tooltip. g_hInst … | |
i did several ways and nothing work correctly. i have 2 controls: 1 - label: with an animation; 2 - the tooltip is showed on top until the label is re-painted. so is there another way for put the control, always, on top? | |
see my property constructor: template <typename T> class property { private: T PropertyValue; std::function<T(void)> getf; std::function<void(T)> setf; public: property(const T &value) { getf=nullptr; setf=nullptr; PropertyValue=value; } property(const property &value) : PropertyValue(value.PropertyValue) , getf(value.getf) { } property(std::function<T(void)> GetFunction=nullptr,std::function<void(T)> SetFunction=nullptr) { setf=SetFunction; getf=GetFunction; } inside a class i have 2 functions: void … | |
i have 1 pen drive, that is my network. how can i disable, these pen(but not all pens) or program been automatic executed? (the windows connect to network automatic, so i don't need the program been executed) | |
from MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/dd145213%28v=vs.85%29.aspx "An application returns zero if it processes this message." see these code on my label control: case WM_PAINT: { PAINTSTRUCT test; BeginPaint(inst->hwnd, &test); image imglabel(inst->imgtest.width(),inst->imgtest.height()); brush brshbackcolor(inst->clrBackColor); imglabel.Backcolor=inst->clrBackColor; brush brshTransparent; FillRect(imglabel,&test.rcPaint,brshbackcolor); if(inst->imgtest.haveimage()) DrawHICONtoHDC(imglabel, inst->imgtest); imglabel.DrawText(inst->strCaption); pen penColor(1,2,RGB(0,255,0)); penColor.ToDC(imglabel); imglabel.DrawRectangle(10,10,10,10); pen penColor2(1,2,RGB(255,0,0)); penColor2.ToDC(imglabel); imglabel.DrawLine(0,0,20,20); pen penColor3(1,2,RGB(0,0,255)); penColor3.ToDC(imglabel); //brshTransparent.ToDC(imglabel); … | |
i belive that my brother found a virus\spyware. i even formated the laptop and continues there :( my problem is: the help window is allways opening. i have problems using the laptop :( ca anyone help me? | |
how can i copy the parent background(DC) control to child control DC? | |
i have notice that using the joyGetPosEx() function, when the joystick isn't connected, that the memory, that the application uses, is increasing. so is there another way just for see if 1 joystick is connected to pc? | |
how send a message with WM_DRAWITEM message? heres my actual code on parent window: case WM_DRAWITEM: { DRAWITEMSTRUCT *test=(DRAWITEMSTRUCT*) lParam; /*if(test->CtlType==ODT_MENU) { MENUITEMINFO menuInfo; menuInfo.cbSize = sizeof(MENUITEMINFO); menuInfo.fMask=MIIM_DATA; if(GetMenuItemInfo((HMENU)test->hwndItem,(UINT) test->itemID, TRUE, &menuInfo )!=0) { Menu *mMenu = (Menu *) menuInfo.dwItemData; if(mMenu!=NULL) if(mMenu->DrawItem!=NULL) //mMenu->DrawItem(); else { } } } else { … | |
think in these way: the eyes have the blue color, the backcolor is blue. so how can i change the backcolor without change the image\eye? (these is just an exemple for trying explain) | |
heres my image class: class image { private: ULONG_PTR m_gdiplusToken; Gdiplus::GdiplusStartupInput gdiplusStartupInput; HDC hdcimage=CreateCompatibleDC(NULL); HGDIOBJ obj=NULL; HBITMAP btBitmap=NULL; Image *img; bool isimgused=false; int imageheight=0; int imageweight=0; int framecount=0; int intSelectFrame=0; int framedelay=0; string strfilename=""; Gdiplus::Color clrBackColor=Gdiplus::Color::Transparent; HDC hdcwindow; bool blnTransparent=true; HICON HICONFromHBITMAP(HBITMAP bitmap) { BITMAP bmp; GetObject(bitmap, sizeof(BITMAP), &bmp); HBITMAP … | |
finally i have the static control transparent: //creating the form: hwnd = CreateWindowEx(0, classname, strCaption.c_str(),WS_OVERLAPPEDWINDOW | WS_TABSTOP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, mod, this); //sending a message for subclassing: case WM_CTLCOLORSTATIC: { return DefWindowProc(HandleWindow, msg, wParam, lParam); } break; //heres how i create a static control with ownerdraw style: … | |
heres my image class: class image { private: ULONG_PTR m_gdiplusToken; Gdiplus::GdiplusStartupInput gdiplusStartupInput; HDC hdcimage=CreateCompatibleDC(NULL); HGDIOBJ obj=NULL; HBITMAP btBitmap=NULL; Image *img; bool isimgused=false; int imageheight=0; int imageweight=0; int framecount=0; int intSelectFrame=0; int framedelay=0; string strfilename=""; Gdiplus::Color clrBackColor=Gdiplus::Color::Transparent; HDC hdcwindow; bool blnTransparent=true; HICON HICONFromHBITMAP(HBITMAP bitmap) { BITMAP bmp; GetObject(bitmap, sizeof(BITMAP), &bmp); HBITMAP … | |
the control have the WS_TRANSPARENT style. and: case WM_ERASEBKGND: { return TRUE; } break; case WM_CTLCOLORSTATIC: { return (LRESULT)GetStockObject(NULL_BRUSH); } break; case WM_DRAWITEM: { DRAWITEMSTRUCT *test=(DRAWITEMSTRUCT*) lParam; image imglabel(test->rcItem.right-test->rcItem.left,test->rcItem.bottom-test->rcItem.top); if(inst->blnTransparent!=true) FillRect(test->hDC,&test->rcItem, CreateSolidBrush(inst->clrBackColor)); else FillRect(test->hDC,&test->rcItem,(HBRUSH) GetStockObject(NULL_BRUSH)); FillRect(imglabel,&test->rcItem,CreateSolidBrush(inst->clrBackColor)); if(inst->imgtest.haveimage()) DrawHICONtoHDC(imglabel, inst->imgtest,1,1); SetBkMode(imglabel,TRANSPARENT); char *text=(char*)inst->strCaption.c_str(); SetTextColor(imglabel,inst->clrTextColor ); DrawTextEx(imglabel,text,-1,&test->rcItem,DT_LEFT,NULL); if(inst->blnBorder==true) DrawEdge(imglabel, &test->rcItem,BDR_SUNKENINNER | BDR_RAISEDOUTER,BF_RECT); … | |
when the form is activated: case WM_ACTIVATE: { if (wParam==WA_INACTIVE) { SetWindowText(inst->hwnd,"unactivated"); FormActivated = NULL; } else { SetWindowText(inst->hwnd,"activated"); FormActivated = inst->hwnd; } return 0; } break; when i create the timer: 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 , … | |
the RegisterHotKey() is limited? everytime that i create a button control the RegisterHotKey() id isn't the same. //on constructor: ++ButtonCount; altmessage=ButtonCount; now the hotkey message: case WM_HOTKEY: { if (wParam==inst->altmessage) { SendMessage(inst->hwnd,WM_COMMAND,BN_CLICKED,lParam); } } break; and now how i regist the hot key: case WM_DRAWITEM: { DRAWITEMSTRUCT *test=(DRAWITEMSTRUCT*) lParam; UnregisterHotKey(inst->hwnd,inst->altmessage); … | |
i'm trying overload the != and == operators, but i'm getting several errors :( bool operator==(const image &other) const { if(other.btBitmap==*this->btBitmap) return true; else return false; } bool operator!=(const image &other) const { return !(*this == other); } what i'm doing wrong? | |
how can i do the control autosize? i think in these way: 1 - get the text rect: RECT textrect; int a=DrawText (test->hDC,inst->strCaption.c_str(),-1,&textrect,DT_CALCRECT); (the a isn't zero) 2 - testing the rectangle with image size: if(textrect.bottom<inst->imgtest.height()) inst->intHeight=inst->imgtest.height(); if(textrect.right<inst->imgtest.width()) inst->intWidth=inst->imgtest.width(); 3 - change the control size: SetWindowPos(inst->hwnd, 0, 0, 0, inst->intWidth, … | |
i'm owner draw some controls. here what i use for a button: case WM_DRAWITEM: { DRAWITEMSTRUCT *test=(DRAWITEMSTRUCT*) lParam; HIMAGELIST imlIcon=ImageList_Create(inst->imgtest.width(),inst->imgtest.height(),ILC_COLOR,1,1); ImageList_Add(imlIcon,inst->imgtest,NULL); HTHEME hTheme = OpenThemeData(inst->hwnd, L"BUTTON"); //fill the background with button face color FillRect(test->hDC, &test->rcItem,(HBRUSH) GetSysColor(COLOR_BTNFACE)); if ( test->itemState & ODS_SELECTED) // If it is pressed { DrawEdge(test->hDC,&test->rcItem,EDGE_SUNKEN,BF_RECT); // Draw … | |
i have 1 class Timer. the class works fine, but when the windows loses the focus, the timer stops... why these happens? | |
i can show an icon on notify area: NOTIFYICONDATA NID; //on main NID.cbSize = NOTIFYICONDATA_V2_SIZE; //if i use the NOTIFYICONDATA_V3_SIZE //the compiler enters on conflits NID.hIcon = test2; NID.uCallbackMessage = WM_USER + 1; NID.hWnd = a; NID.uID = 01; NID.uVersion=4; NID.uTimeout=500; NID.dwInfoFlags = NIIF_INFO; strcpy(NID.szInfoTitle, "Test Title"); //NID.hBalloonIcon=(HICON)test2;//no member strcpy(NID.szTip, … | |
my image class can read animated gif's. using a timer i can change the menu item image. but when the menu item is showed, how can i refresh it? (i have tryied the DrawMenuBar() and SetMenu() without sucess. the image is, only, updated when i move the mouse from 1 … | |
can i change the HBITMAP structure for be transparent? because the gif's files are show me a black background color. | |
i have these code for show popupmenus: 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; the menu is showed normaly, but why the click message isn't working? heres the … | |
when do: operator HBITMAP() { HBITMAP hbitmap=CreateBitmap(imageweight,imageheight,1,32,NULL);//create the bitmap with icon size SelectObject(hdcimage, hbitmap);//add the bitmap to memory DC MessageBox(NULL,to_string(GetLastError()).c_str(),"error",MB_OK); return hbitmap; } the hdcimage is copyied to hbitmap, right? | |
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? | |
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? | |
using the WM_KEYUP, can i see if the shift\control\alt keys was uped too? | |
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; … | |
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? | |
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; } … | |
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) … | |
i know move the mouse for where i want. but how can send a click message to another program? | |
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 … | |
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? | |
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); … | |
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 … | |
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 … | |
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 … | |
i'm trying building a BITMAP from memory, but isn't easy :( //create the button HandleButton=CreateWindowEx (0,"button", "hello\t\tHI", WS_CHILD | WS_VISIBLE | BS_TEXT | BS_BOTTOM |BS_BITMAP, 100, 100,500, 200,hwnd, (HMENU)4000,hInstance, 0) ; //create a dc and bitmap in memory HDC memoryDC =CreateCompatibleDC(GetDC(hwnd)); HBITMAP bitmap=CreateCompatibleBitmap(GetDC(hwnd),500,200); SelectObject(memoryDC, bitmap); //get the icon HandleIcon=(HICON)LoadImage(hInstance,"C:\\acrobat.ico",IMAGE_ICON,SM_CXICON,SM_CYICON,LR_LOADFROMFILE | … | |
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 … | |
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 … | |
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 … | |
i'm creating the form class. the form us showed and the window procedure works. the problem is that some messages(like WM_CREATE) aren't working. so how can i connect, correctly the form to window procedure? | |
i'm build a function for do the combination of keys(like the kombat games: we do some combination keys for do an actions): bool CombineKeys(std::vector<int> const keys) { static bool PreviousKeyPressed; static DWORD StartTimer = GetTickCount(); static int i=0; if((GetAsyncKeyState(keys[0]) & 0x8000) and PreviousKeyPressed==false) { i=0; SetWindowText(a,"hello"); PreviousKeyPressed=true; i++; } else … | |
i'm build a completed new code for properties: #include <iostream> #include <functional> using namespace std; template <typename T> class property { private: T PropertyValue; //i think these is ok, but something seems not std::function<T(void)> getf; std::function<void(T)> setf; public: property() { getf=NULL; setf=NULL; }; property(T value) { PropertyValue=value; }; property(std::function<void(void)> GetFunction=NULL,std::function<T(void)> … | |
my mobile batery is BL-5F: - 950mAh; - 3,7V; - 3,5Wh. the BL-6F: - 1200mAh; - 3,7V; - 4,4Wh. the have the connection in same place. the 6F give me much more time with mobile.. and the Volts are the same. but i'm confused with Wh. it's bad give more … | |
i put an image on form with WM_PAINT message. but the image is, only, showed after resize(for example) the form. why is that? did i forget any style\extended style? | |
heres a nice tutorial about regions: http://www.flipcode.com/archives/Win32_Window_Skinning.shtml like you see, these tutorial is for forms.. so how we can do with child controls!?! we can: add the WS_CLIPCHILDREN or WS_CLIPSIBLINGS style, when we create a button\other control: hwnd = CreateWindowEx( 0, TEXT("CBUTTON"), strCaption.c_str(), WS_CHILD | WS_VISIBLE | BS_TEXT | WS_TABSTOP … | |
heres the code that i use for put the form transparent: LONG style= GetWindowLong(hwnd, GWL_EXSTYLE); style=style | WS_EX_LAYERED; SetWindowLong(hwnd, GWL_EXSTYLE, style); SetLayeredWindowAttributes(hwnd, clrBackColor, NULL, LWA_COLORKEY); but i see problems :( the form and the controls are showed, but the mouse events are ignored. if i click on button or form, … |
The End.