Search Results

Search found 746 results on 30 pages for 'winapi'.

Page 1/30 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to resize window using WinAPI

    - by Evl-ntnt
    I'm want resize window using WinAPI. I use WinAPI function SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); Window is resized, but window content is not redrawed. If I resize this window using mouse, content redraws. How to resize window using WinAPI with content redrawing?

    Read the article

  • The most elegant way to encapsulate WinAPI callbacks inside a class

    - by FractalizeR
    Hello. I am thinking about elegant way to encapsulate WinAPI callbacks inside a class. Suppose I am making a class handling asynchronous I/O. All Windows callbacks should be stdcall functions, not class methods (I need to pass their addresses to ReadFileEx WinAPI function for example). So, I cannot just pass method addresses as a callback routines to WinAPI functions. What is the most elegant way to encapsulate functionality of this type inside a class so that the class have events OnReadCompleted and OnWriteCompleted (I am using Delphi as a primary language, but I guess the situation must be the same in C++ because class methods are different from simple methods by the fact, that the first hidden parameter of them is this link. Of course this class is not a singleton and there can be many of them created by app at the same time. What do you think would be the good way to implement this?

    Read the article

  • Importing a DllMain winapi .dll into Visual Studio project C++

    - by Bad Man
    I have the .def file, .lib file, the .dll, the source files. It's using WINAPI DllMain, all its functions follow that. It's like this: BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } extern "C" { int WINAPI DoSomething() { return -1; } int WINAPI DOSOMETHIGNELSE!() { return 202020; } }; IN the project settings linker I added the .lib file. There is no header file for the actual functions in the extern "C" part. I include windows.h try to call DoSomething() but doesnt know what it is.

    Read the article

  • How to use WINAPI from newer SDK but still using the old SDK in WindowsMobile.

    - by afriza
    Specifically, I want to use Point-to-point Message Queue but because I am still using legacy codes in eVC++ 4 and it only support until PocketPC 2003SE SDK, I cannot find CreateMsgQueue and friends in the headers (the port to newer VisualStudio is still in progess) I am using the Message Queue to do IPC with apps developed with WM-6.5-DTK (VS2005). Update: I am using the following code (taken from msgqueue.h) to store function pointers and load CoreDLL.dll using GetProcAddress() and LoadLibrary() respectively. HANDLE /*WINAPI*/ (*CreateMsgQueue)(LPCWSTR lpName, LPMSGQUEUEOPTIONS lpOptions); HANDLE /*WINAPI*/ (*OpenMsgQueue)(HANDLE hSrcProc, HANDLE hMsgQ , LPMSGQUEUEOPTIONS lpOptions); BOOL /*WINAPI*/ (*ReadMsgQueue)(HANDLE hMsgQ, /*__out_bcount(cbBufferSize)*/ LPVOID lpBuffer, DWORD cbBufferSize, LPDWORD lpNumberOfBytesRead, DWORD dwTimeout, DWORD *pdwFlags); BOOL /*WINAPI*/ (*WriteMsgQueue)(HANDLE hMsgQ, LPVOID lpBuffer, DWORD cbDataSize, DWORD dwTimeout, DWORD dwFlags); BOOL /*WINAPI*/ (*GetMsgQueueInfo)(HANDLE hMsgQ, LPMSGQUEUEINFO lpInfo); BOOL /*WINAPI*/ (*CloseMsgQueue)(HANDLE hMsgQ); Is the above code alright since I need to comment out WINAPI and __out_bcount(cbBufferSize) in order for them to compile.

    Read the article

  • WinApi equivalent of .NET KeyPreview

    - by user146780
    In .Net there is a feature called KeyPreview. How can I do this in WinApi. Maybe I don't necessarily need this but my hWnd has WM_KEYDOWN, but it does not receive it when my Text Box has focus. How can I achieve this? Thanks *Using pure Win32API... is there an alternative, how could I handle the Text Box's WM_KEYDOWN?

    Read the article

  • [winapi] Three questions about editbox ?

    - by subSeven
    Hello! I have three questions about editbox control in WINAPI (i can't find information on msdn about this) 1. How to disable moving typeing cursor with mouse, arrows, backspace in editbox ? I want to make typing like in command line in dos, but with out backspace. Can I write some piece of text with red color, and another with blue ? How to write to editbox control from another thread ?

    Read the article

  • Auto scrolling control (WinAPI)?

    - by user146780
    In C# (.Net) you can create a panel and set autoscroll to true. you can then add controls into it, including beyond it's size, then it will scroll. I was wondering if when using the real WinAPI in c++ (not .net) how one could acheive the same result. Must I keep track of the controls inside and move them all when I scroll or is there an easier way like in C#. Thanks

    Read the article

  • C++/WinAPI - Hardcoding the resources in application

    - by HardCoder1986
    Hello! I have some code which shows a simple dialog box and handles user action (written using plain WinAPI). // Display dialog and handle user action LRESULT choice = DialogBoxParam(NULL, MAKEINTRESOURCE(AP_IDD_DIALOG), NULL, (DLGPROC)DialogCallback, NULL); Is there any way to hardcode the resource file dialog.rc, which is used to build the dialog ?(I would like to get rid of .rc files and I'm pretty sure there is a way, yet I don't know what it is :)

    Read the article

  • WinAPI C - RunAsUser from REDMON_USER and REDMON_SESSIONID

    - by scriptmaster
    I installed a PostScript printer driver and have setup REDMON (redmonnt.dll) for redirecting postscript output to my program. In my rather simple c program I capture the data from STDIN and I am able to successfully save it into a .ps file. The file looks OK. However, I want to start gsview.exe for viewing the file. If I call ShellExecute it fails in Windows 7 because of permission issues. It seems that my program is called under a different user account (LOCAL SERVICE). So I am looking for a way to run gsview.exe under a specific username (the user who initiated the print job is available to me in a variable as REDMON_USER along with the SESSIONID as well. I am stuck (and my stack is overflowing =) What are the minimum WinAPI call I need to use to launch a program given a username and a sessionid? Any code examples in C/C++, .NET would be very helpful

    Read the article

  • Skinning WinAPI Controls

    - by Brad
    If you've ever seen an application in the Adobe Creative Suite 5 (CS5), you may have noticed that it doesn't look like the native Windows GUI.. They have modified it to have a different look to it. Where would someone begin to make an application that has a custom skin? CS5 uses the Adobe Source library for it's widget/control management, so I tried downloading and compiling the Adobe Source Library to see if I could make a nice skinned app like Photoshop CS5, but after finally getting it to compile and tested it, I realized the library was only for managing widgets and not skinning the GUI, like CS5 has. Where would I begin to make a nice skinned program like Adobe Cs5 applications? Can anyone point me in the right direction? Do I simply use the WM_PAINT Message from WinAPI and render my own widgets using openGL or something?

    Read the article

  • Window screenshot using WinAPI

    - by Evl-ntnt
    How to make a screenshot of program window using WinAPI & C#? I sending WM_PAINT (0x000F) message to window, which I want to screenshot, wParam = HDChandle, but no screenshot in my picturebox. If I send a WM_CLOSE message, all waorking (target window closes). What I do wrong with WM_PAINT? May be HDC is not PictureBox (WinForms) component? P.S. GetLastError() == "" [DllImport("User32.dll")] public static extern Int64 SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); ..... SendMessage(targetWindowHandle, 0x000F, pictureBox.Handle, IntPtr.Zero);

    Read the article

  • Using WINAPI ReadConsole

    - by Jim Fell
    I am trying to use the WINAPI ReadConsole() to wait for any keypress at the end of my Win32 console application. CONSOLE_READCONSOLE_CONTROL tControl; char pStr[65536]; DWORD dwBufLen = 1; DWORD dwCtl; tControl_c.nLength = sizeof( CONSOLE_READCONSOLE_CONTROL ); tControl_c.nInitialChars = 0; tControl_c.dwControlKeyState = 0; tControl_c.dwCtrlWakeupMask = NULL; pBuf[0] = 0x00; do { ReadConsole( hConsole_c, pStr, (*pBufLen) * sizeof(TCHAR), pBufLen, &tControl ); } while ( pStr[0] == 0x00 ); The code executes without throwing an exception. However, when the ReadConsole() function executes the error code ERROR_INVALID_HANDLE (0x06) is flagged. I have verified hConsole_c to be a valid handle. Does anyone have any insight as to what I am doing wrongly? I am using Visual C++ 2008 Express Edition. Thanks.

    Read the article

  • Frame skipping with OpenGL and WinAPI?

    - by user146780
    Here is my situation. I'm creating a drawing application using OpenGL and WinAPI. My OpenGL frame has scrollbars which renders the screen and modifies GlTranslatef when it gets a scroll message. The problem is wen I get too many shapes the scrollbar is less responsive since it cannot rerender it each and every time it gets a scroll message. How could I make it so the scrollbar has priority. I want it to skip drawing if it would compromise the smoothness of the scrolling. I thought of doing rendering on a separate thread but I was told all UI things should stay on the same thread. Thanks

    Read the article

  • How to encapsulate a WinAPI application into a C++ class

    - by Semen Semenych
    There is a simple WinAPI application. All it does currently is this: register a window class register a tray icon with a menu create a value in the registry in order to autostart and finally, it checks if it's unique using a mutex As I'm used to writing code mainly in C++, and no MFC is allowed, I'm forced to encapsulate this into C++ classes somehow. So far I've come up with such a design: there is a class that represents the application it keeps all the wndclass, hinstance, etc variables, where the hinstance is passed as a constructor parameter as well as the icmdshow and others (see WinMain prototype) it has functions for registering the window class, tray icon, reigstry information it encapsulates the message loop in a function In WinMain, the following is done: Application app(hInstance, szCmdLIne, iCmdShow); return app.exec(); and the constructor does the following: registerClass(); registerTray(); registerAutostart(); So far so good. Now the question is : how do I create the window procedure (must be static, as it's a c-style pointer to a function) AND keep track of what the application object is, that is, keep a pointer to an Application around. The main question is : is this how it's usually done? Am I complicating things too much? Is it fine to pass hInstance as a parameter to the Application constructor? And where's the WndProc? Maybe WndProc should be outside of class and the Application pointer be global? Then WndProc invokes Application methods in response to various events.

    Read the article

  • I want to write a program to control the square moving by using WINAPI

    - by code_new
    This is the code as attempted so far: #include <windows.h> LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppname[] = TEXT ("win0") ; WNDCLASS wndclass ; MSG msg ; HWND hwnd ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.cbWndExtra = 0 ; wndclass.cbClsExtra = 0 ; wndclass.lpfnWndProc = WndProc ; wndclass.lpszClassName = szAppname ; wndclass.lpszMenuName = NULL ; wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; wndclass.hInstance = hInstance ; if (!RegisterClass (&wndclass)) { MessageBox (NULL, TEXT ("Register fail"), szAppname, 0) ; return 0 ; } hwnd = CreateWindow ( szAppname, TEXT ("mywin"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL) ; ShowWindow (hwnd, iCmdShow) ; UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam ; } LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int cxClient, cyClient, Left, Top, Right, Down ; PAINTSTRUCT ps ; HDC hdc ; RECT rect ; Right = 20 ; Down = 20 ; switch (message) { case WM_SIZE : cxClient = LOWORD (lParam) ; cyClient = HIWORD (lParam) ; return 0 ; case WM_PAINT : hdc = BeginPaint (hwnd, &ps) ; SetRect (&rect, Left, Top, Right, Down) ; FillRect (hdc, &rect, CreateSolidBrush (RGB (100, 100, 100))) ; EndPaint (hwnd, &ps) ; return 0 ; case WM_KEYDOWN : InvalidateRect (hwnd, &rect, TRUE) ; switch (wParam) { case VK_UP : if (Top - 20 < 0) { Top = 0 ; Down = 20 ; } else { Top -= 20 ; Down -= 20 ; } SendMessage (hwnd, WM_PAINT, wParam, lParam) ; break ; case VK_DOWN : if (Down + 20 > cyClient) { Down = cyClient ; Top = Down - 20 ; } else { Down += 20 ; Top += 20 ; }SendMessage (hwnd, WM_PAINT, wParam, lParam) ; break ; case VK_LEFT : if (Left - 20 < 0) { Left = 0 ; Right = 20 ; } else { Left -= 20 ; Right -= 20 ; }SendMessage (hwnd, WM_PAINT, wParam, lParam) ; break ; case VK_RIGHT : if (Right + 20 > cxClient) { Right = cxClient ; Left = Right - 20 ; } else { Right += 20 ; Left += 20 ; }SendMessage (hwnd, WM_PAINT, wParam, lParam) ; break ; default : break ; } return 0 ; case WM_DESTROY : PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam); } I considered that I didn't deal the message well, so I can't control it.

    Read the article

  • Communication with HyperTerminal [ QT and WINApi ]

    - by javaAmator
    Hi! I write program to communicate with modem (it useing Hayes commands) and this is working. GUI is programmed with QT, but communication with COM port is write with winapi library. I have problem when I want to send with my program message from one computer to another, i can't send Polish chars (they are repleaced by '?'), how can I fix it ? Does anyone have idea ?? And I have one more problem, I can't send message from my program to Microsoft HyperTerminal, HyperTerminal receive something, but not that what I send. Thx for any help :) Important pieces of code: Connect with port: portHandle = CreateFile (portName, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); GetCommState (portHandle, &dcb); switch(ui->comboBox->currentIndex()) { case 0 : dcb.BaudRate=CBR_110; break; case 1 : dcb.BaudRate=CBR_300; break; case 2 : dcb.BaudRate=CBR_600; break; case 3 : dcb.BaudRate=CBR_1200; break; case 4 : dcb.BaudRate=CBR_2400; break; case 5 : dcb.BaudRate=CBR_4800; break; case 6 : dcb.BaudRate=CBR_9600; break; case 7 : dcb.BaudRate=CBR_14400; break; case 8 : dcb.BaudRate=CBR_19200; break; case 9 : dcb.BaudRate=CBR_38400; break; case 10 : dcb.BaudRate=CBR_56000; break; case 11 : dcb.BaudRate=CBR_57600; break; case 12 : dcb.BaudRate=CBR_115200; break; case 13 : dcb.BaudRate=CBR_128000; break; case 14 : dcb.BaudRate=CBR_256000; break; } dcb.fBinary = TRUE; dcb.fParity = TRUE; dcb.fOutxCtsFlow = FALSE; dcb.fOutxDsrFlow = FALSE; dcb.fDtrControl = DTR_CONTROL_ENABLE; dcb.fDsrSensitivity = FALSE; dcb.fTXContinueOnXoff = TRUE; dcb.fOutX = FALSE; dcb.fInX = FALSE; dcb.fErrorChar = FALSE; dcb.fNull = FALSE; dcb.fRtsControl = RTS_CONTROL_ENABLE; dcb.fAbortOnError = FALSE; //dcb.ByteSize = dataBits; dcb.DCBlength = sizeof (DCB); switch(ui->comboBox_3->currentIndex()) { case 1 : dcb.Parity = EVENPARITY; break; case 3 : dcb.Parity = MARKPARITY; break; case 2 : dcb.Parity = ODDPARITY; break; case 4 : dcb.Parity = SPACEPARITY; break; case 0 : dcb.Parity = NOPARITY; break; } switch (ui->comboBox_4->currentIndex()) { case 0 : dcb.StopBits = ONESTOPBIT; break; case 1 : dcb.StopBits = ONE5STOPBITS;break; case 2 : dcb.StopBits = TWOSTOPBITS; break; } switch (ui->comboBox_2->currentIndex()) { case 0 : dcb.ByteSize = 5; break; case 1 : dcb.ByteSize = 6;break; case 2 : dcb.ByteSize= 7; break; case 3 : dcb.ByteSize = 8; break; } SetCommState (portHandle, &dcb); GetCommTimeouts (portHandle, &CommTimeouts); CommTimeouts.ReadIntervalTimeout = MAXDWORD; CommTimeouts.ReadTotalTimeoutMultiplier = 0; CommTimeouts.ReadTotalTimeoutConstant = 0; CommTimeouts.WriteTotalTimeoutMultiplier = 10; CommTimeouts.WriteTotalTimeoutConstant = 1000; SetCommTimeouts (portHandle, &CommTimeouts); Send MSG: void MainWindow::Send(char c) { do {WriteFile(portHandle, &c, 1, &cbWritten, NULL); } while (!(cbWritten)); } void MainWindow::on_pushButton_clicked() { QString str = ui->lineEdit->text(); std::string str2; ui->lineEdit->clear(); str2 = str.toStdString(); for(int i=0; i < str2.size();i++) { Send(str2[i]); //qDebug()<< str2[i]; } Send(char(13)); } Receive MSG: void ReaderThread::run() { char c; while(1) { c = Receive(); if(c==13) { emit insertPlainText("\n"); } else { emit insertPlainText(QString(c)); } } } char ReaderThread::Receive() { char c; do{ ReadFile(portHandle, &c, 1, &cbRead, NULL); } while (!(cbRead)); return c; }

    Read the article

  • C: WinAPI CreateDIBitmap() from byte[] problem

    - by zipcodeman
    I have been working on this problem for a while now. I am trying to add JPEG support to a program with libjpeg. For the most part, it is working fairly well, But for some JPEGs, they show up like the picture on the left. It may not be obvious, but the background shows up with alternating red green and blue rows. If anyone has seen this behavior before and knows a probable cause, I would appreciate any input. I have padded the rows to be multiples of four bytes, and it only slightly helped the issue.

    Read the article

  • mouse_event WinAPI call not working when cursor is over Flash

    - by friederbluemle
    Hi, I am writing a small program which can simulate mouse clicks at specified positions. Using the Win32 API call mouse_event like so: [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo); [Flags] public enum MouseEventFlags : uint { LEFTDOWN = 0x00000002, LEFTUP = 0x00000004, MIDDLEDOWN = 0x00000020, MIDDLEUP = 0x00000040, MOVE = 0x00000001, ABSOLUTE = 0x00008000, RIGHTDOWN = 0x00000008, RIGHTUP = 0x00000010 } mouse_event((uint)(MouseEventFlags.LEFTDOWN | MouseEventFlags.LEFTUP), x, y, 0, UIntPtr.Zero); Works perfectly fine, except when the mouse cursor is over a Flash application. Flash seems to ignore the simulated mouse click. What could be the reason for this? And how do I fix it? Thank you!

    Read the article

  • Custom form designer, move/resize controls using WinAPI

    - by jonny
    I have to fix some problems and enchance form designer written long ago for a database project. In Design Panel class code I encountered these lines private void DesignPanel_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { (sender as Control).Capture = false; switch (FMousePosition) { case MousePosition.mpNone: SendMessage((sender as Control).Handle, WM_SYSCOMMAND, 0xF009, 0); break;// Move case MousePosition.mpRightBottom: SendMessage((sender as Control).Handle, WM_SYSCOMMAND, 0xF008, 0); break;//RB case MousePosition.mpLeftBottom: SendMessage((sender as Control).Handle, WM_SYSCOMMAND, 0xF007, 0); // ... here are similar cases ... case MousePosition.mpLeft: SendMessage((sender as Control).Handle, WM_SYSCOMMAND, 0xF001, 0); break;//L } } } FMousePosition indicates whether mouse was over any edge of selected control. What confusing me is these windows messages: it seems there is no documentation on WM_SYSCOMMAND with parameters 0xF001-0xF009 (maybe it starts some kind of 'drag/resize sequence'). Any ideas? If my suggestion is right, then how can I cancel these sequences?

    Read the article

  • winapi c - read/write mbr of system drive

    - by kiasecto
    Does anyone have any example code that shows how to identify the system boot harddisk, and read/write the mbr from the harddisk in windows xp and vista? I know createfile can be used. But I do not know how to properly identify which device is the boot device. Like how do you find out which ones you are meant to use? \.\Volume{GUID}\ or \?\Device\HarddiskVolumeX etc?

    Read the article

  • Pointless 'MIDL_INTERFACE' Macro in winapi?

    - by nebukadnezzar
    After browsing some old code, I noticed that some classes are defined in this manner: MIDL_INTERFACE("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") Classname: public IUnknown { /* classmembers ... */ }; However, the macro MIDL_INTERFACE is defined as: #define MIDL_INTERFACE(x) struct in C:/MinGW/include/rpcndr.h (somewhere around line 17). The macro itself is rather obviously entirely pointless, so what's the true purpose of this macro?

    Read the article

  • RichEdit, winapi - paragraph aligment

    - by bartek
    Hi, I would like to have a line aligned in such way, that some first words are aligned left and some last words are aligned right, but all are in the same line: | text 1 text2 | | Lorem ipsum dolor sit amet | Is that possibile? How can I do that?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >