how to create, initialize, and maintain a memory device context that works as a local buffer for images? The idea is to maintain some large images in local DCs and bitmaps, and only bitblt them to screen in OnDraw().
What I did so far was was to define CDC and CBitmap objects as members of my View class, and then tried to initialize them with the sequence that begins at "// Initialize buffer". I placed that sequence in either OnInitialUpdate, or PreCreateWindow, or OnPrepareDC, or the view constructor, to no avail. The code always crashes in OnDraw, and I've noticed that the m_hDC member of myDevice is zero at that point.
Obviously, the initialization is wrong and MFC does (too many) things in the background which I'm not aware of.... My question was where can I read about that?
Code: class CMyView : public CScrollView { // ... CDC myDevice; CBitmap bmp; CBitmap *oldbmp;
When using wxWidgets, i am tempted to deallocate memory using delete in the destructor, but my program crashes on closing. I try to do something like this:
class mainwnd:public wxFrame{ public: mainwnd():wxFrame(NULL,wxID_ANY,wxT("test")){ menubar=new wxMenuBar;
I'm trying to determine (from my Win32 process) if a Metro (or a Modern UI) app is currently displayed on the screen. I found the IAppVisibility::GetAppVisibilityOnMonitor method that can do just that, and I even found a C++ sample, but my issue is that I'm compiling it with the Visual Studio 2008 that does not have the definitions for the IAppVisibility interface, so the following:
I want to display my image on window without saving it.
When data is received window size changes but there is no display on window.
My Code is:
Code:
int iBufferLength; int iEnd; int iSpaceRemaining; int i; iBufferLength = iSpaceRemaining = sizeof(chIncomingDataBuffer); iEnd = 0; iSpaceRemaining -= iEnd;
This program is incomplete as I am having difficulty creating the function that needs to find the number of perfect scores entered by the user. I have everything but the function complete ,here is my code:
Code: // Write a modular program that accepts at least 10 integer test scores from the user and stores them in an array. // The main should display how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function. // Input validation: Do not accept scores less than 0 or greater than 100.
#include <iostream> using namespace std; int countPerfect(int intArray[], int); // Function prototype
==39800== Invalid free() / delete / delete[] / realloc() ==39800== at 0x4D9D: free (vg_replace_malloc.c:477) ==39800== by 0x10000C471: Tokenizer::~Tokenizer() (in ./a.out) ==39800== by 0x10000C424: Tokenizer::~Tokenizer() (in ./a.out) ==39800== by 0x100001B8B: main (in ./a.out) ==39800== Address 0x10002a778 is 8 bytes inside a block of size 7,208 alloc'd
I am using C++ new/delete operators to allocate/deallocate the buffers. I think for each allocated buffer, there should be an additional info block stores the size and other info about the buffer. How to know more details about this info block? I need to override these two operators and find such an info block is useful to my implementation.
I am overriding OnSaveDocument in my MFC document class to strip out the carriage returns when saving my app's document to a UNIX file system but not when the user is saving a file to a Windows file system.
Is there a way to determine if the lpszPathName in OnSaveDocument(LPCTSTR lpszPathName) is a UNIX or Windows file system?
Note, I want to avoid hard coding server names and I want to avoid overriding the FileSave dialog and forcing the user to select Windows or UNIX.
I want to send data from a laptop (windows 7, processor 2.60GHz) to a desktop (windows xp, processor 3.10GHz) using serial communication (using a USB to RS232 convertor). The WriteFile function is able to send the data from the laptop (NumberOfBytesWritten is correct). But on the desktop side, ClearCommError detects no data in the read buffer.
This is the relevant code in my desktop:
while(1) { ClearCommError(hPort,&dwErrors,&commStatus); if (commStatus.cbInQue != 0) ReadFile(hPort,&data,1,&dwBytesRead,NULL); Sleep(10); }
The if condition is never satisfied. The baudrate and other parameters in the DCB struct are the same on both sides.
The same code works when I write and read in the same system by shorting the RX and TX pins in the RS232 connector.
I'm having some issues with my code. For the produce function i am getting an error saying 'no instance of overload function produce() matches the argument list' and also for the lines buffer[head].data = message; buffer[head].time = current_time i get an error saying 'expression must have pointer to object type.
In the code i'm not sure if i passed the variables to the function correctly. I have attached the code .....
What is the efficiency of the two assignments (line 1 and 2), i.e. (function calls, number of copies made, etc), also the Big O notation. I know there are function calls for retrieving the size of each string in order to produce a new buffer for the concatenated string...any difference between line 1 and 2 in terms of efficiency?
String s("Hello"); String t("There"); 1. s = s + t; 2. s += t;
I made a simple little program that takes text from the clipboard, and spits out all the lines I've copied one at a time (so my program can analyze it).
everything works perfectly, except, it spits it own in the wrong order, I want it to spit out from bottom to top. but currently it spits out the data from top to bottom. here is my code :
Code: #include <iostream> #include <Windows.h> #include <string> #include <sstream> using namespace std; int main() { HANDLE clip; // assigns the var. clip to hold a handle ID.
[Code] .....
I want this loop to run backwards! Like it say's what I want to work backwards. Where as I know how to flip a while loop like this: while(x < 5), how to flip a loop like the one I'm using. how I can do this?
I have an int array of size 5 and I have my program to accept 5 integers between 10 and 100 inclusively. I should be able to type integers over and over again until I get 5 that are in the range, 10 <= x <= 100. Now when I get 5 that fall in that range the program should continue but instead it wants a 6th number before continuing. I'm suspecting the program is hanging on to a new line character. Anyway to ignore the new lines? Couldn't find anything for C# without clearing the screen.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DupElim { //dup elimination
Im creating a permissions profiler in c by using stat()I ran into a problem of getting a bad address as in my path. Ive tried multiple solutions with no dice, and now I have one more solution I want to try but I dont understand how.how do you use a snprintf and pass that into a buffer, and pass that into a path for stat()?
I`ve wrote a function for my utility to XOR char* buffer by a key, then to reverse it with the same key. Here is the code, it`s simple enough:
Code:
static inline char* XOR_buffer(const char* d, const char* k ) { char *newstr = (char*) malloc(sizeof(char)* strlen(d)); newstr[0]=''; printf("%d is size of string ", strlen(d)); char *begin = newstr; char* ret = begin; int len = strlen(k); }
[code]....
The lengh of the string is reduced by the second XOR call. You can try it out, just define XORDBG to view the error message in the second pass to the buffer.
I want to use a const char* as a buffer. I am reading values from a file and adding them to a buffer. How to extract the values is simple enough. I am reading through a filestream, reading each character into a char pointer and progressing that char pointer every time. I have another char pointer marking the start positon
eg.
char *mychar = new char; char *char1 = new char; char *char2 = new char; const char *constchar ; char2 = char1; while(filestream.read(mychar,1) { *char1 = *mychar; ++char1; }
Then I get this problem: constchar = mychar; // const char* = char*.
Constchar does not catch all the data in other words. At some stage some data is lost due to zeros in the data.. How can I put values into a const char and get around this problem? The const char* will //only record everything up until the first zero.
I'm trying to analyze buffer text, but unfortunately i'm not able to do so... My approach
Code: // here i'm getting and reading text from the user bzero(buffer, 1024); read(m_Socket, buffer, 1023); string inputText; inputText = string(buffer);