Visual C++ :: Can't Make Double-buffered Painting With Multiple Monitors

Sep 19, 2012

I'm trying to remake my Windows screensaver written with C++ and WinAPIs to work on multiple monitors. I found this article that gives the basics. But when I implement it in my own code, I get a weird result. Take a look at this code:

Code:
case WM_PAINT: {
PAINTSTRUCT ps = {0};
HDC hdcE = BeginPaint(hWnd, &ps );
EnumDisplayMonitors(hdcE, NULL, MyPaintEnumProc, 0);
EndPaint(hWnd, &ps);

[code]....

Painting always works on a primary monitor. But when I paint to the secondary monitor, I can only paint directly to its DC. When I use double-buffering technique (with DIRECT_PAINT pre-processor directive commented out) I only get a black screen on a secondary monitor when it should've been red.

First one with direct painting that works:

and then the one that doesn't, with double-buffering technique:

View 12 Replies


ADVERTISEMENT

Visual C++ :: Calling Default In OnNcPaint Before Painting Override Caption?

Jun 20, 2013

I'm overriding OnNcPaint to do my own caption painting (in a dialog box). If I call "Default" before I do my painting, the default caption and borders remain (as if I'm not painting at all). If I comment out my call to "Default", my caption looks great, but I get no menu bar (I have a menu on the dialog). If I call "DrawMenu" before or after painting, the dialog is all screwed up (and there is no painting in the nonclient area).

I'm running VS2012, on Windows 7.

View 10 Replies View Related

C/C++ :: How To Make Multiple Subroutine And Return Multiple Arrays

Aug 17, 2014

how to make subroutines and return multiple arrays.Before that, i wrote my program on matlab. could my program to be structured as following?

<header>
initial value of program;
subroutine1() {
calculating the first work;
return 2 or 3 arrays;

[code].....

View 14 Replies View Related

C++ :: How To Make Median Display As Double

Feb 8, 2015

How do i make the median display as a double?

#include <iostream>
#include <conio.h>
#include <cstdlib>
#include <ctime>
using namespace std;
int main {
int* randomArray(int, int); /*This function creates an array of random numbers
of a given size within a given range*/

[Code]...

View 2 Replies View Related

C++ :: Converting Multiple Lines Of Strings To Double

Aug 26, 2014

I am trying to convert multiple lines of strings to double with std::stod .... I used the code found on the website:

#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
int main() {
std::string two_doubles =" 22145.365 -3564789";
std::string::size_type K;
double first = std::stod (two_doubles, &K);
double second = std::stod (two_doubles.substr(K));
}

The string starts with white spaces. I get this error message when compiling:

warning unused variable 'first'
warning unused variable 'second'

How do you convert the two numbers in the string two_doubles to doubles?

View 2 Replies View Related

C/C++ :: Program That Monitors Downstream Speed Realtime

Feb 14, 2015

I want to create a program in windows, it will search for a process/program by name or part of its name and monitor real-time at certain intervals the data speed at each moment that are received from the internet by this process/program. So that when no data is received by the process/program the speed will be zero and i will know it.

Can i do it in c or c++ , if yes then what libraries should i look into to do it and if i can not with these then what language and libraries should i look into to create the program?

View 1 Replies View Related

C++ :: How To Make Multiple Endlines

Jan 20, 2013

Is there a way to make multiple endl instead of using the following:

cout << endl << endl << endl

View 3 Replies View Related

C++ :: Painting Company - Calculate Amount Of Paint Required For Every Contract

Dec 15, 2014

You work for a painting company. Your job is to calculate the amount of paint needed for every contract assigned to the company. This time, you need to paint an outside wall. The dimensions of the wall are 5 X 7m. The window is a circle with the radius of 1m. Write a program that would calculate the following:

The amount of paint needed knowing that you need 1 gallon per 10 square meters. The amount of time to complete the job knowing that it takes 1 hour per 10 square meters to prepare the surface, 5 minute per square meter to pant it and 5 minute per square meter to clean up the area.

View 8 Replies View Related

C :: How To Make Custom Program For Packaging Multiple Files In One

Nov 5, 2014

I want to make a custom program for packaging multiple files in one. Not as complicated as ZLIB or others. Consider few files, XML, txt, JPG, OGG, I want them to be added in 1 file. Not visible not readable. Just a datafile. I have some ideas about creating some kind of indexing of the start byte, end byte of each file. But I am still way too far. Can you point me some direction at what should I stress in creating this software. It will be portable since I am planning to use stdlib, stdio only, maybe and string to recreate the filenames from the large chunk datafile.

View 2 Replies View Related

C++ :: Make A Table Class That Will Be Able To Have Multiple Columns Of Data?

Sep 17, 2014

I am trying to make a table class that will be able to have multiple columns of data. I want it to have something to hold data (I was using a 2D vector for only one data type) in it, somewhat like a pair, but for any number of data types. The class is a template to make it generalized.

I have looked a little at variadic templates, but I don't know how to declare the vectors for each data types then.

View 4 Replies View Related

C :: How To Emulate Object Orientation With Multiple Files And Make File

Feb 13, 2013

how to structure my classes so that they all "wire together" and inherit the proper functions and data that I want them to. I want to have a Car.c and car.h which are "wired" with body.c/body.h, which in turn is wired with a frame.c/frame.h, wheel.c/wheel.h, and driver.c/driver.h.

Each part of the car holds some type of data, mostly ints: The car has a (total) mass and car_name. The body has a mass and color. The frame has a mass. The wheel(s) have a mass and force. [There will be 4 instances of wheel] The driver has a mass and driver_name. Each of these functionalities must come from their respective .c and .h files, and be amalgamated in the car.c and car.h (which should contain all the functionality of its parts). Then, in my main test program, I am to make an instance of car and hardcode in its values of: mass (which comes from the total mass of all of its parts, this is where i start to lose it.

How will I access its parts' masses in the test program?), color (a character array), current position (an integer), current velocity (an integer), and current acceleration (which comes from the total newton force of the 4 wheels, again this is where I start to get very confused). (Then in the test program I am to print out a simulation of this car over a period of 100 seconds, and show its position, velocity, and acceleration at each point (based on the mass, total newton force, and starting position). This part is of course a simple while loop, and is somewhat trivial.)

From what I understand, I will need to allocate memory for all of the data each class holds. Then, using function pointers, as well as #include "X.h" , I will need to somehow link up all of the classes together so that car has access to all of the parts' functions which set, for example, the newton force of each wheel.

We have learned a slight bit about structs, malloc, sizeof, and pointers, but I have not used them to link functionality or data from separate classes together.

View 4 Replies View Related

Visual C++ :: Comparison Of 2 Double Values

Dec 27, 2013

I have std::vector of players and each player have its own value. The value is of the type double, but the original value are of the "XX.00".

Now what I'm trying to do is to insert a player into this vector. For that I need to find a place and to find a place I need to compare player value.

So lets say I have a player in the vector whose value is 24.00 and I am trying to insert a player whose value is 25.00. To my surprise MSVC 2010 tells me that:

24.0000000000000 == 25.00000000000

I do aware that comparing double type is not going to work like this, but I would expect not to have such big of a difference. ;-)

Why this comparison is true and how to eliminate such thing?

View 3 Replies View Related

Visual C++ :: String To Double Conversion?

Nov 22, 2013

I have the following piece of code:

string ss = findNodeValue( str, "Horizon");
cout << "ss is: " << ss << endl;
double dd = atof( ss.c_str());
cout << "dd is: " << dd << endl;

When the value of 'ss' is printed, I find it prints 1.0, but when the value of 'dd' is printed, it prints 1 whereas it is supposed to print 1.0.

View 2 Replies View Related

Visual C++ :: Difference Between Double And Int64

Jul 31, 2013

1) What is the range of numbers covered by a 64-bit double?

2) Ignoring fractions, is the above range wider or narrower than the range covered by an int64?

View 14 Replies View Related

Visual C++ :: Convert 8 Bytes Into Double And Back?

Sep 5, 2013

I receive a byte stream. The first 8 bytes contain an Identification number. I receive at first the lowest byte and at the end the highest byte of the number. How can I transform this into a double value and later back into the bytestream? In the past I hard only 2 Byte values and there I could use things like MAKEWORD and HIBYTE and LOWBYTE to convert the values

View 4 Replies View Related

Visual C++ :: Error In Finding Lowest Double In Array

Oct 25, 2014

When I run the program, when it displays the lowest temtpature, it shows the address instead of the actual number.

Code:
/*********************************************
* File: b.cpp
* Description: Create a C++ program that declares a 100-element array of doubles representing temperature readings. Pass the array to a function to be partially filled by the user. When the user is done entering temperatures, the function should return the number of elements added to the array. The main function should then display the maximum and minimum temperatures in the array.
***********************************************/

#include <iostream>
using namespace std;
//prototypes
void getData(double arr[]);

[Code] ....

View 2 Replies View Related

Visual C++ :: Multiple Selections For Uploading

Jul 13, 2013

How do you select multiple folders and upload them. Search recursively? I cant find any code or examples.

View 2 Replies View Related

Visual C++ :: Rounding A Number Multiple Of Another

Jul 23, 2013

How would I be able to round a number in multiples of another...

Let's say width is 150
And multiple to be 64...
I want 150 to become 128...
if it was 160 to become 192...

The width number will change and I want to covert it in multiples of the other number example 64... The minimum value will always be the multiple number used...

View 7 Replies View Related

Visual C++ :: Sum Multiple Group To Find The Max

Dec 17, 2013

How to sum groups in C++? I have a class with 2 attributes (Group and Price). I need to find the group with the highest amount. I can find the max when it comes to finding a set of individual numbers but not when a group is required. For Ex:

Group A64
Group A48
Group A18
Group B49
Group B36
Group C64
Group C75
Group C87
Group C72

The group with the highest amount is GROUP C

View 14 Replies View Related

Visual C++ :: Macro With Multiple Parameters

Oct 22, 2014

In the following example, SET_DARKENING_PARAMETERS_0 is a fairly simple macro which accepts 9 parameters. The first one is called driver and the other 8 are all ints. Basically, the 8 x ints get assigned to the first 8 elements of an array which is owned by driver. I can call the macro successfully if I do this:-

Code: SET_DARKENING_PARAMETERS_0 ( some_driver, 500, 400, 1000, 275, 1667, 275, 2333, 0 );

But in the actual code I'm trying to compile, the 8 x ints are themselves encoded into a secondary macro like this:-

Code: #define CONFIG_OPTION_DARKENING_PARAMETERS 500, 400, 1000, 275, 1667, 275, 2333, 0

So the actual code (to call SET_DARKENING_PARAMETERS_0) looks like this:-

Code: SET_DARKENING_PARAMETERS_0 ( some_driver, CONFIG_OPTION_DARKENING_PARAMETERS );

But the two combined macros won't compile with VC8. Basically, I get warning #C4003 (not enough parameters for macro 'SET_DARKENING_PARAMETERS_0') followed by a load of syntax errors. However, the code (allegedly) compiles with gcc.

I'm wondering if macro CONFIG_OPTION_DARKENING_PARAMETERS might be getting truncated to just 500, (with the following parameters getting ignored)?

View 5 Replies View Related

Visual C++ :: Unable To Make Addon To IE

Dec 7, 2013

I am trying to make an add-on to IE. This add-on doesn't have any tool bar or any UI.

I am just taking the details of currently loaded HTML page. Basically it is for manipulating one dialog box. I want to get access to the DOM COM interfaces of the dialog box.

Since it doesn't have any button I didn't impliment IOleCommandTarget. I implemented only IObjectWithSIte.

My RGS file contain following in addition to my COM related entries

HKLM
{
NoRemove SOFTWARE
{
NoRemove Microsoft
{

[Code]...

But I couldn't see my add-on working or even not loading to IE.

View 4 Replies View Related

Visual C++ :: Can Only Make Video With 255 Frames

May 4, 2015

I have code (found long time ago, ~2001) to make videos from OpenGL rendering in my view class. In my OnDraw() function I call the function SaveAsAvi(). This works as intended until I have 255 frames in the movie I am trying to make. After that, Windows Media Player claims it cannot play the file. VirtualDub claims the avi contains Palette Changes and shows the correct number of frames (>255) but all frames past 255 are the same and equal to the last frame.

Memory overflow? Need to free m_pixels sometime somewhere?

Code:
void C***View::SaveAsAvi() {
C***Doc* pDoc = GetDocument();
if (pDoc->m_avi_status == -1)// initialize AVI stuff {
KillTimer(1);
// allocate space for the pixel info

[Code] ....

View 1 Replies View Related

Visual C++ :: CFileDialog Multiple Selection Limit?

Apr 30, 2013

In my attempt to capture multiple files using CFileDialog I discovered that there is a limit on the number of characters in the file name buffer. [URL]

I have used this code to get the file names and it works fine up to the point where the buffer is full. NB: m_vcsPathnames and m_vcsFilenames are std::vector<CString> types.

Code:
// get a list of the files to process
wchar_t szFilters[]= _T("All Files (*.*)|*.*||");
// Create an Open dialog; the default file name extension "*.*"
CFileDialog fileDlg(TRUE, _T(""), _T("*.*"),
OFN_FILEMUSTEXIST| OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilters, this);
m_vcsPathnames.resize(0);

[code]....

Is there any possible work around for this limitation, other than completely writing my own CFileDialogExx class ?

View 6 Replies View Related

C++ :: Make Visual Studios Step Into A Function?

May 2, 2013

if there is a way to make Visual Studios step into a function while I am debugging.. I am trying to see the value of a certain int and making sure it is what I need it to be.. but whenever I use step into visual studios just skips right over the function and it does all the calculations..

View 4 Replies View Related

Visual C++ :: How To Make Icon For MSVC Project

Oct 22, 2013

I'm developing a software for Windows using MSVC 2010. My employer sent me 2 png files: 16x16 and 32x32 for the icons.

What I would like to do is to use them as a MSVC icon resource and don't use any code hacks. In the past all I had was an ico file and I just included it in the resource (rc) file for Visual Studio and that was it.

Now my question is: how do I make one ico file out of those 2 png files that will be accepted by MSVC? Is there a tool (preferably free) for it or some online service?

View 3 Replies View Related

Visual C++ :: How To Make Random Array To Not Repeat

Feb 17, 2013

Here is my code for a simple game. paste it and try it.

#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
int main (void) {
stringg[4],

[code]...

What they do (enter 4 actions)?

";
for (int ai = 0; ai < 4; ai++)
getline(cin, a[ai]);
cout << "

Where is happening (enter 4 locations)?

";
for (int li = 0; li < 4; li++)
getline(cin, l[li]);
for (int c = 0; c < 4; c++)
cout << g[rand() % 4] << " and " << b[rand() % 4] << " are " << a[rand() % 4] << " from a " << l[rand() % 4] << endl;
return (0);
}

At the end in the 4 lines some of the names, actions and locations repeat. How do I make them to not repeat and use every name that you will enter? do I need random_shuffle? How can I integrate it in my code?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved