Search Results

Search found 3339 results on 134 pages for 'pure win32'.

Page 19/134 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Win32 -- Object cleanup and global variables

    - by KaiserJohaan
    Hello, I've got a question about global variables and object cleanup in c++. For example, look at the code here; case WM_PAINT: paintText(&hWnd); break; void paintText(HWND* hWnd) { PAINTSTRUCT ps; HBRUSH hbruzh = CreateSolidBrush(RGB(0,0,0)); HDC hdz = BeginPaint(*hWnd,&ps); char s1[] = "Name"; char s2[] = "IP"; SelectBrush(hdz,hbruzh); SelectFont(hdz,hFont); SetBkMode(hdz,TRANSPARENT); TextOut(hdz,3,23,s1,sizeof(s1)); TextOut(hdz,10,53,s2,sizeof(s2)); EndPaint(*hWnd,&ps); DeleteObject(hdz); DeleteObject(hbruzh); // bad? DeleteObject(ps); // bad? } 1)First of all; which objects are good to delete and which ones are NOT good to delete and why? Not 100% sure of this. 2)Since WM_PAINT is called everytime the window is redrawn, would it be better to simply store ps, hdz and hbruzh as global variables instead of re-initializing them everytime? The downside I guess would be tons of global variables in the end _ but performance-wise would it not be less CPU-consuming? I know it won't matter prolly but I'm just aiming for minimalistic as possible for educational purposes. 3) What about libraries that are loaded in? For example: // // Main // int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // initialize vars HWND hWnd; WNDCLASSEX wc; HINSTANCE hlib = LoadLibrary("Riched20.dll"); ThishInstance = hInstance; ZeroMemory(&wc,sizeof(wc)); // set WNDCLASSEX props wc.cbSize = sizeof(WNDCLASSEX); wc.lpfnWndProc = WindowProc; wc.hInstance = ThishInstance; wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MYICON)); wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.lpszClassName = TEXT("PimpClient"); RegisterClassEx(&wc); // create main window and display it hWnd = CreateWindowEx(NULL, wc.lpszClassName, TEXT("PimpClient"), 0, 300, 200, 450, 395, NULL, NULL, hInstance, NULL); createWindows(&hWnd); ShowWindow(hWnd,nCmdShow); // loop message queue MSG msg; while (GetMessage(&msg, NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } // cleanup? FreeLibrary(hlib); return msg.wParam; } 3cont) is there a reason to FreeLibrary at the end? I mean when the process terminates all resources are freed anyway? And since the library is used to paint text throughout the program, why would I want to free before that? Cheers

    Read the article

  • Add Ellipsis to a Path in a WinForms Program without Win32 API call (revisited)

    - by casterle
    I was searching for a way to insert an ellipsis in a C# path, and found an answer here on stackoverflow: http://tinyurl.com/y6rmdfr Using the RTM versions of VS2010 and .Net 4.0, I was unable to get the suggested method to work. I searched the 'Net and found example code that uses the same method, but it failed in the same way. You can see the string I'm trying to shorten in my code below. After calling the MeasureText method, both the input string (OriginalName) and the output string (ellipsisedName) look like this: d:\abcd\efgh\ijkl\mnop\qrst\...\test.txt\0F\GHIJ\KLMN\OPQR\STIV\WXYZ\test.txt Two problems: 1) The resulting string is narfed (the path is truncated as expected, but is followed by what looks like a C-style terminating null and a chunk of the original path). 2) My original string is changed to be identical to the output string. Am I doing something wrong? namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); string OriginalPath = @"d:\abcd\efgh\ijkl\mnop\qrst\uvwx\yzAB\CDEF\GHIJ\KLMN\OPQR\STIV\WXYZ\test.txt"; string ellipsisedPath = OriginalPath; Size proposedSize = new Size(label1.Width, label1.Height); TextRenderer.MeasureText(ellipsisedPath, label1.Font, proposedSize, TextFormatFlags.ModifyString | TextFormatFlags.PathEllipsis); } } }

    Read the article

  • adding a dll to a VS 2008 Win32 application

    - by Ayusman
    Hi, I have created a project VC++ in VS 2008. I want to call a certain function in an external dll. How can I add the reference/resource [I am a java guy please forgive if I am using the wrong terms here] to my project so that I can call the functions in the dll. I have gone through several forums and yet have not found a clear solution. Please help. TIA Ayusman

    Read the article

  • PDCurses TUI with C++ Win32 console application

    - by Bach
    I have downloaded pdcurses source and was able to successfully include curses.h in my project, linked the pre-compiled library and all good. After few hours of trying out the library, I saw the tuidemo.c in the demos folder, compiled it into an executable and brilliant! exactly what I needed for my project. Now the problem is that it's a C code, and I am working on a C++ project in VS c++ 2008. The files I need are tui.c and tui.h How can I include that C file in my C++ code? I saw few suggestions here but the compiler was not too happy with 100's of warnings and errors. How can I go on including/using that TUI pdcurses includes!? Thanks EDIT: I added extern "C" statement, so my test looks like this now, but I'm getting some other type of error #include <stdio.h> #include <stdlib.h> using namespace std; extern "C" { #include <tui.h> } void sub0(void) { //do nothing } void sub1(void) { //do nothing } int main (int argc, char * const argv[]) { menu MainMenu[] = { { "Asub", sub0, "Go inside first submenu" }, { "Bsub", sub1, "Go inside second submenu" }, { "", (FUNC)0, "" } /* always add this as the last item! */ }; startmenu(MainMenu, "TUI - 'textual user interface' demonstration program"); return 0; } Although it is compiling successfully, it is throwing an Error at runtime: 0xC0000005: Access violation reading location 0x021c52f9 at line startmenu(MainMenu, "TUI - 'textual user interface' demonstration program"); Not sure where to go from here. thanks again.

    Read the article

  • WM_NOTIFY and superclass chaining issue in Win32

    - by DasMonkeyman
    For reference I'm using the window superclass method outlined in this article. The specific issue occurs if I want to handle WM_NOTIFY messages (i.e. for custom drawing) from the base control in the superclass I either need to reflect them back from the parent window or set my own window as the parent (passed inside CREATESTRUCT for WM_(NC)CREATE to the base class). This method works fine if I have a single superclass. If I superclass my superclass then I run into a problem. Now 3 WindowProcs are operating in the same HWND, and when I reflect WM_NOTIFY messages (or have them sent to myself from the parent trick above) they always go to the outermost (most derived) WindowProc. I have no way to tell if they're messages intended for the inner superclass (base messages are supposed to go to the first superclass) or messages intended for the outer superclass (messages from the inner superclass are intended for the outer superclass). These messages are indistinguishable because they all come from the same HWND with the same control ID. Is there any way to resolve this without creating a new window to encapsulate each level of inheritance? Sorry about the wall of text. It's a difficult concept to explain. Here's a diagram. single superclass: SuperA::WindowProc() - Base::WindowProc()---\ ^--------WM_NOTIFY(Base)--------/ superclass of a superclass: SuperB::WindowProc() - SuperA::WindowProc() - Base::WindowProc()---\ ^--------WM_NOTIFY(Base)--------+-----------------------/ ^--------WM_NOTIFY(A)-----------/ The WM_NOTIFY messages in the second case all come from the same HWND and control ID, so I cannot distinguish between the messages intended for SuperA (from Base) and messages intended for SuperB (from SuperA). Any ideas?

    Read the article

  • Win32 api call via C# fails!

    - by user434186
    Hi. I have a C++ function exported as api like this: #define WIN322_API __declspec(dllexport) WIN322_API char* Test(LPSTR str); WIN322_API char* Test(LPSTR str) { return "hello"; } the function is exported as API correctly by the .DEF file, cause i can see it in Dependency Walker tool. Now i have a C# tester program: [DllImport("c:\\win322.dll")] public static extern string Test([MarshalAs(UnmanagedType.LPStr)] String str); private void Form1_Load(object sender, EventArgs e) { string _str = "0221"; Test(_str); // runtime error here! } on calling the Test() method i get the error: "A call to PInvoke function 'MyClient!MyClient.Form1::Test' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature." i tried many other data types and marshalings, but got nothing! plz help me!

    Read the article

  • win32 ruby1.9 regexp and cyrillic string

    - by scriper
    #coding: utf-8 str2 = "asdf????????" p str2.encoding #<Encoding:UTF-8> p str2.scan /\p{Cyrillic}/ #found all cyrillic charachters str2.gsub!(/\w/u,'') #removes only latin characters puts str2 The question is why \w ignore cyrillic characters? I have installed latest ruby package from http://rubyinstaller.org/. Here is my output of ruby -v ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32] As far as i know 1.9 oniguruma regular expression library has full support for unicode characters.

    Read the article

  • Which plugin framework to use for native C++/Win32

    - by Kerido
    Hi everybody. I have an extensible product that allows 3rd party developers to extend it. The aspects that can be extended are documented and interfaces are provided in the SDK. Currently, I'm using COM and I'm getting pretty comfortable with it. I especially like the ability to provide interface versioning in a unified manner. I consider it to be a requirement because you never know what you're gonna need in the future. Just to be precise, here's an example. Let's suppose I have an interface representing a particular feature: class IFeature { public: virtual void DoFeatureTask() = 0; }; Then after the interface is already documented (and someone may have used it in the plugin code) I'm realizing, I need more from this feature. Maybe, there is an option I need to provide. I just define the second version: class IFeature2 { public: virtual void DoFeatureTask(int theOption) = 0; }; I don't mean I intend to have lots of versions. But it just may happen. In COM, because every interface is associated with a GUID, I can query a preferred implementation, determine its presence, and, finally, fall back to a legacy one. But after glancing through C++/COM-related questions, I noticed many recommendations against COM. So maybe it's not the best choice and I'm just too old-school. Can you advise on an alternative?

    Read the article

  • How to extract a GUID from a Win32 DLL or OCX

    - by Paul Sasik
    We have a .NET app that needs to examine a folder that may contain COM libraries (DLL and OCX.) When we do encounter a COM library one thing we need to accomplish is to extract the GUID from the COM DLL or OCX. Is there a straightforward way to do this with .NET without using 3rd party libraries?

    Read the article

  • win32:libs undefined reference

    - by hector
    I want to link a .lib in my Qt project and I get an error about an undefined reference to vhtIOConn::getDefault(vhtIOConn::DeviceType). I have already added the following specifications to the .pro file: ###################################################################### # Automatically generated by qmake (2.01a) vie 28. ago 12:48:10 2009 ###################################################################### TARGET = DEPENDPATH += . INCLUDEPATH += . LIBS += "C:\agregar\VirtualHandCore.lib" LIBS += "C:\agregar\VirtualHandDevice.lib" LIBS += "C:\agregar\VirtualHandRegistry.lib" # Input HEADERS += "C:/Documents and Settings/halvarado/Mis documentos/respaldos de Qt/Development/include/vhandtk/vhtBase.h" SOURCES += main.cpp What should I do?

    Read the article

  • Get newly created window using Win32 API hooks

    - by Nathan W
    This may be a long short or not even possible but no harm in asking. What I am trying to do is monitor an application for any new windows it creates in its MDI control. I have implemented hooking in C# and can capture the MDICREATE window message but because I need to get information about the window after is has been created the MDICREATE message isn't much help because at that stage the window hasn't been created in the other application yet. Without going into to much detail I just need to be able to see when a new window has been created. Is this possible? Thanks

    Read the article

  • win32: TextOut not being displayed

    - by KaiserJohaan
    Hello again, I recently having my mainwindow write text by using WM_PAINT, but now I realise it was maybe not the best message to do so in, so I'm trying another version; The mainwindow contains a menu, upon clicing a menu item the ID_FILE_PID msg is sent and it builds the 4 new windows aswell as displays text in the mainwindow (paintEditSigns function). The 4 windows works fine but the text dosn't work at all, unless I do it in the main() function as shown... what on earth is this? O_O BTW: I still have no clue why the code-display on StackOverflow keeps looking so wierd when I post, why is this? switch(message) { case WM_COMMAND: switch (LOWORD(wParam)) { case ID_FILE_PID: { HWND hWndButton; HWND hWndEdit; HWND hWndEdit2; HWND hWndDisplay; // drawing the text in mainwindow paintEditSigns(); -- does not do anything here! // adding new windows in the mainwindow hWndButton = CreateWindowEx(0,TEXT("BUTTON"),"Modify",WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 170,56,80,30,hWnd,(HMENU)ID_BUTTON,hThisInstance,NULL); hWndEdit = CreateWindowEx(0,RICHEDIT_CLASS,TEXT(""),WS_CHILD | WS_VISIBLE | WS_BORDER, 120,30,80,25,hWnd,(HMENU)ID_EDIT,hThisInstance,NULL); hWndEdit2 = CreateWindowEx(0,RICHEDIT_CLASS,TEXT(""),WS_CHILD | WS_VISIBLE | WS_BORDER, 220,30,80,25,hWnd,(HMENU)ID_EDIT2,hThisInstance,NULL); hWndDisplay = CreateWindowEx(0,TEXT("STATIC"),NULL,WS_CHILD | WS_VISIBLE | WS_BORDER, 0,100,450,140,hWnd,(HMENU)ID_DISPLAY,hThisInstance,NULL); break; } ..... // // Main function // int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hWnd; WNDCLASSEX wc; ZeroMemory(&wc, sizeof(WNDCLASSEX)); hThisInstance = hInstance; LoadLibrary("Riched20.dll"); wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.hInstance = hInstance; wc.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU); if(!(wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MYICON)))) { HRESULT res = GetLastError(); } wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.lpszClassName = TEXT("testcpp"); RegisterClassEx(&wc); hWnd = CreateWindowEx(NULL, wc.lpszClassName, TEXT("test"), WS_OVERLAPPEDWINDOW, 300, 200, 450, 300, NULL, NULL, hInstance, NULL); ShowWindow(hWnd,nCmdShow); //paintEditSigns() -- here it works, but not when in the message part MSG msg; while (GetMessage(&msg, NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } void paintEditSigns() { HFONT hf = createFont(); PAINTSTRUCT ps; HWND hWnd = FindWindow(TEXT("testcpp"),TEXT("test")); HBRUSH hbruzh = CreateSolidBrush(RGB(0,0,0)); HDC hdz = BeginPaint(hWnd,&ps); string s = "Memory Address"; SelectBrush(hdz,hbruzh); SelectFont(hdz,hf); TextOut(hdz,0,100,s.c_str(),s.length()); EndPaint(hWnd,&ps); DeleteObject(hbruzh); UpdateWindow(hWnd); } HFONT createFont() { HDC hdc; long lfHeight; hdc = GetDC(NULL); lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72); ReleaseDC(NULL, hdc); HFONT hf = CreateFont(lfHeight, 0, 0, 0, 0, TRUE, 0, 0, 0, 0, 0, 0, 0, "MS Sans Serif"); return hf; }

    Read the article

  • OpenCL C/C++ dynamic binding library (win32 and more)

    - by rotoglup
    I'm giving a try at OpenCL, and in order to put this in production I'd like to be able to bind dynamically to OpenCL.DLL (when under Windows), in order to handle 'gracefully' the case where no OpenCL is installed on the host computer. Is there any available library (or code snippet) that takes care of this dynamic binding in C or C++, much like GLEW does for OpenGL ? I'd like to avoid the hassle to do it myself. Thanks,

    Read the article

  • Fast method of directory enumeration on Win32?

    - by BillyONeal
    Hello everyone :) I'm trying to speedup directory enumeration in C++, where I'm recursing into subdirectories. I currently have an app which spends 95% of it's time in FindFirst/FindNextFile APIs, and it takes several minutes to enumerate all the files on a given volume. I know it's possible to do this faster because there is an app that does: Everything. It enumerates my entire drive in seconds. How might I accomplish something like this?

    Read the article

  • Win32 script environment for testing http redirects?

    - by Anders Lindahl
    The past few days I've been working with setting up an Apache server on Windows. The server is supposed to host several .htaccess files, each redirecting (or, in some cases, proxying) to different hosts. I want to create tests for these redirectons, and the solution I'm currently considering is a CGI script running on the same server, sending GET requests to it and verifying that it gets the correct redirection headers back. A scripting solution (vscript/jscript) seems worth exploring, but so far I've only managed to rule out Microsoft.XMLHTTP because it follows the redirect "behind the scenes". Are there any libraries or other solutions already present on a reasonably standard Windows Server that can do this kind of low-level HTTP work? If not, any other suggestions of simple environments to set up for verifying redirects?

    Read the article

  • Install Python 2.6 without using installer on Win32

    - by prosseek
    I need to run a python script on a machine that doesn't have python installed. What I did was as follows. Copy python.exe, python26.dll, msvcr90.dll and Microsoft.VC90.CRT.manifest zip all the directory in LIBs directory as the python26.zip copy all the necessary dll/pyd file inside the DLL directory. It seems to work, but when I change the python26.zip to the other name such as pythonlib.zip. It cannot find the python library anymore. Q1 : What's the magic behind the python26.zip name? The python automatically finds a library inside a python26.zip but not with different name? Q2 : If I have python26.zip at the same directory where python.exe/python26.dll is, I don't need to add path sys.path.append(THE PATH TO python26.zip). Is it correct?

    Read the article

  • Multi color Edit Field (Win32)

    - by user146780
    I want to create a program that will parse text for key words and make these words a certain color. What type of control supports many different colors? Would I have to create my own, or override the OnPaint() of a basic control or something? (Id like to avoid making my own control from scratch) Thanks

    Read the article

  • Alternate for MoveTo and LineTo in win32, MFC

    - by mukesh
    Hi i am working on some high resolution display features in which have to draw the vertical line , i am using Moveto() and lineTO() , but it is much time taking... can anyone suggest me , what we can use instead of it ...to optimize the performance... see the scene is , in order to draw 100 Vertical lines it is taking 84ms time, we need to reduce it to 5 ms something.. please refer me any alternate fot that. Thanks, Mukesh

    Read the article

  • How does the performance of pure Nginx compare to cpNginx?

    - by jb510
    There is now a Cpanel plugin to fairly easily setup Nginx as a reverse proxy on a Cpanel/Apache server. I've been simultaneously interested in setting up my first unmanaged VPS and my first Nginx server and as a masochist figured why not combine the two. I'm wondering however if it's worth setting up a pure Nginx server vs trying out cpNginx on Apache? My goal is solely to host WordPress sites and while what I've read raves about Nginx's is exceptional ability serving static at least as a reverse proxy, I am unclear if there is substantial benefit to running a pure nginx with eAccelorator over cpNginx on Apache for dynamic sites? Regardless I'll be running W3TC on all sites to cache content, but am still interested if there are big CPU reductions running PHP scripts under pure Nginx over cpNginx?

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >