Visual C++ :: Draw Multiple Lines And Move Them On Screen

Jul 28, 2013

I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines.

I have created rectangle region for each line and trying to move the line.

When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.

How can I rectify it. How can I have all the lined being on the screen and moved according to the user's wish. The code should be pure C and win32 no MFC.

View 4 Replies


ADVERTISEMENT

Visual C++ :: Floating CDialogbar On Multiple Screen Environment

Jul 11, 2014

I have an problem with a CDialogbar if my app runs on a system with two screens (side by side). I can not resize it while the CDialogbar is in floating state on the second screen.

I figured out that the problem is the mfc-function CDockContext::Stretch().

It limits the CDialogbar to the primary screen (using ::GetDesktopWindow() to verify the position).

What can I do?

View 2 Replies View Related

C++ :: How To Draw Lines With Different Colors

Nov 8, 2014

I want to write a function called DrawLineSegments.This function must change the color of lines at every corner where the corner angle is greater than 60 deg (Assume that there is a function called checkangle). The color sequence must be black, red, green, blue, and repeat this sequence after the fourth color.

View 1 Replies View Related

C++ ::  How To Move Characters On Screen Using Keyboard

Dec 3, 2013

How to move a character (an arrow or any other character) on screen using keyboard? I'm actually a beginner and have only wrote simple (starter's) programs in C++. It would be great without using any external library which is not included in C++ by default (in other words, using plain C++).

View 8 Replies View Related

C/C++ :: Game Of Fifteen - Swap Move Not Showing On Screen

May 26, 2014

I am having problems with my game of fifteen. I have implemented the swap> I know the swap takes place[using GDB] but the swap does not show on the screen even if GDB says it has taken place. I am getting no errors from the move function so I know that something is taking place. I was thinking that the problem may be in the draw function but it looks okay to me. I have looked at this over and over but I don't know why the draw is not printing the move to the screen.

#define _XOPEN_SOURCE 500
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// board's minimal dimension
#define MIN 3
// board's maximal dimension
#define MAX 9

[Code] ....

View 14 Replies View Related

C++ :: Pacman Game - Move Smiley In Code Automatically And Stop Screen Flickering?

Dec 26, 2013

So far I have managed to write the code for a simple game (resembling to "Pacman") :P. Now what I want is to move the smiley in the upper left-hand corner of the map "automatically" when the program runs and also want it to change it's direction to up or down when it touches the wall.

Also the screen is flickering when the program runs (due to re-printing the whole array?). I want to stop this flicker. Somebody suggested to use 'gotoxy' function.

Here's my code :

#include <iostream>
#include <conio.h>
#include <stdlib.h>
using namespace std;
void display (char array [10][25] , int row , int column) {

[Code] .....

View 8 Replies View Related

C++ :: Draw The Same Sprite Multiple Times (SDL)?

Sep 7, 2014

I have a question about SDL and drawing sprites (SDL surfaces). My idea is that the user can create a wall of separate sprites by create one sprite each time in the current mouseX and mouseY position, when the user push down the e-key. The problem is that I have no idea how I could draw the same sprite multiple times without to delete the previous one.

View 3 Replies View Related

C# :: Draw Multiple Rectangles With Mouse In Picturebox

Jun 6, 2014

I am trying to build a WinForm application that will allow you to load an image into a picturebox and then draw multiple rectangles (empty or translucent) to kind of highlight areas. I want all the rectangles to stay on the image (i can take care of a clear method later). The code below has the latest two attempts I've tried. One is all commented out and the other is not. Both will load the image just fine but neither will allow me to draw/select rectangles on the image.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;

[Code] ....

View 14 Replies View Related

C++ :: Getting Multiple Objects To Move Randomly At A Designated Number Of Intervals

Jan 9, 2015

I have a piece of code which gets multiple objects to move randomly at a designated number of intervals. I want to create a function which calculates the distance between each pair of points after that number of steps. so the distance between object 1 and object 2, object 1 and object 3, ..., object 1 and object N. then object 2 and object 3, object 2 and object 4, ..., object 2 and object N. then then object 3 and object 4, object 3 and object 5, ..., object 3 and object N and so on until the distance between all the pairs of points have been calculated.

#include <ctime>
#include <cstdlib>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<fstream>
#include<vector>

using namespace std;

double dist(int a, int b);
int X(int x1, int x2);
int Y(int y1, int y1);

[Code] ....

View 4 Replies View Related

C++ ::  Loading File With Multiple Lines

May 17, 2014

I'm trying to load a file that look like this:

IP:123.123.123.123
Port:12345

I can't figure out how to load multiple lines. I tried using , but I can't get it to work. Is there a better way of doing it than I am right now? This is my code.

char message[100];
int messageCount = 0;
for(unsigned int i = 0; i < file.size(); ++i) {
message[i] = file[i];

[Code] ....

View 1 Replies View Related

C++ :: How To Store Multiple Lines In Array

Oct 13, 2013

int statarray[] = {61, 66, 47, 50, 372,
62, 66, 47, 50, 372, 50, 54, 64, 45, 331, 49, 52, 58 69, 356,
58, 80, 50, 48, 389, 76, 64, 60, 59, 401, 76, 59, 57, 54, 422,
53, 45, 45, 52, 253};

I'm getting a bunch of different errors with this, how do we do this?

View 2 Replies View Related

C :: Inputting Data From Multiple Lines Using Scanf?

Aug 1, 2013

How would I go about inputting data from multiple lines using scanf?

So far I have tried a loop and somehow checking for '' but can't seem to figure it out..

E.g I want to be able to scanf the ints below line by line and print them( if that makes sense) .

5 15 20 30 5 6
5 6 8 20 34
5 6 7
5 2
2 6 7 2 1 6

This is what i've tried so far, but am really lost!

Code:

int input;
while(scanf("%d", &input)){
printf("%d",input);
if(input == '
'){
continue;}}

View 13 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 :: Void Functions With If Else Construct Not Printing Multiple Lines

Apr 12, 2014

This code i made is a cent converter from 5 to 95 cents. The problem i'm receiving is when the 'cents' function is sent back to the 'main' function it only prints one line. It seems to just print the first if construct that complies with the statement. Is there anyway i can have this function print multiple cent values? For example if 60 cents was entered it would only print '50c', and i want it to print '50c' and '10c' instead.

Code:

#include <stdio.h>
int x;
void check(int x)
{
if( x < 5)
printf("Less then 5 cannot be calculated
");
else if(x > 95)

[code]....

View 3 Replies View Related

C# :: Using MessageBoxButtons Dialog With Multiple Lines Of Text And Parameters

Jan 31, 2014

I am trying to make a messageBoxButtons dialog with the 'yes, no' buttons. Im having trouble because of the multiple lines and parameters already in the message, this means that when i declare the messageBoxButtons.YesNo and the title - it throws an error because of the multiple lines etc...

How can I get the yes/no message box to work in this instance?

class Output {
string text; {
DialogResult dialogResult = MessageBox.Show("Please make sure the following information is correct before submitting."
+ " Date: " + Date
+ " Hours worked: " + Hours
+ " Hourly rate: $" + Rate

[Code] ....

View 5 Replies View Related

C++ :: Program Breaks If Copy Stuff With Multiple Lines Into Console - Clearing Input Buffer

Apr 16, 2014

Using cin.sync() works great so far, but my program still breaks if you copy something with multiple lines into the console.

string test = "";
while(true) {
cin.sync();
getline(cin, test );
cout << endl << "test: " << test << endl;
}

However, if you were to copy this:
1
2
3

and paste it into the program, the output would be1
2
3

test: 1
test: 2

And if you press enter one more time:1
2
3

test: 1
test: 2
test: 3

The 3 finally pops out.

View 2 Replies View Related

Visual C++ :: Draw Buffer With Raw Data?

Nov 19, 2012

Got buffer with raw data. How to display it in MFC dialog and refresh it?

View 3 Replies View Related

Visual C++ :: How To Draw 2D Array Of Data In MFC

Jun 3, 2013

I have a circle of data that is represented as:

vector<vector <unsigned char> >* data;

The first dimension of this vector is the angle of the data so there are 360 angles, and the second dimension is the bins of the data in which there are 512 bins per angle. Each bin has a value from 0 to 15 to determine the intensity of the bin. So basically, when this is all display, there will be a circle of data, with varying colors of intensity at each bin.

What is the best approach to doing this in MFC? How to draw this on the screen?

View 12 Replies View Related

Visual C++ :: Draw Image Using 2D Byte Array?

Feb 8, 2013

I like to Draw an Image Using two dimensional byte array[512][256].

I used SetPixelV method to plot the image.

But Its very slow & hidden some buttons(Controls) at run time in the same dialog.

For reference i send some code,

Code:
for(row = 0; row <512; row ++)
{
for(col = 0; col < 256; col++)
{
Data[row][col] = y;
SetPixelV(d, 10+row, 10+col, RGB(Data[row][col],Data[row][col],Data[row][col]));
}
}

View 14 Replies View Related

Visual C++ :: Draw Grid Over Bitmap In Scrollview

Jul 5, 2013

I have a CScrollView that displays a bitmap and I'm trying to draw a grid that I can turn off and on by check box and when the mouse is over a section of the grid that square highlights... I do all the drawing in the ondraw function... But when I have many grid squares it becomes slow to scroll and to highlight the square the mouse is over... I'm not sure the best way to go about this and where to place code to speed it up... The bitmap is only loaded once... But in ondraw the grid has to redraw every time scrolled and when mouse moved over a square.. In onmousemove I call invalidate so the square under mouse changes...

View 5 Replies View Related

Visual C++ :: How To Draw Pixel-level Color Gradients In CScrollView

Oct 6, 2012

i wish to plot a mathematical function on a 2-dimensional grid. The function will be represented by 3 sets of floats, x-values, y-values, and z-values. Obviously, it is impossible to plot 3 such data sets on a 2D grid, so one approach is to use pixel coloration to represent the z-values.

Those examples (and there are many to be found) show something like the function of the complex variable z, f(z) = exp(z). I have attached a exp(z).jpg example of the imaginary part of the plot exp(z).

My question is: How to accomplish such a gradient colorization, assuming one already has the data?

I have experimented with Gdiplus SetPixel, but I have not figured out how to produce a smooth gradient.

Here's my attempt to create a simple gradient:

Code:
CDC * pDC = GetDC();
Graphics graphics(pDC->m_hDC);
CRect r;
GetWindowRect(&r);
ScreenToClient(&r);

[Code] ....

View 1 Replies View Related

Visual C++ :: Draw A Shape Or Font On Dialog And Then Fill The Outline?

Jul 8, 2013

I am trying to draw a shape or font on dialog and then fill the outline. I have 2 buttons on this 2 buttons I have the following code

Code:
case IDC_BUTTON1:
MessageBox(hDlg, L"Start Drawing!!", L"ButtonPressed", MB_OK | MB_ICONEXCLAMATION);
hDC = GetDC(hDlg);
brush = CreateSolidBrush(RGB(128, 128, 128));
SelectObject(hDC, brush);

[code].....

When I remove the BeginPath() and EndPath() functions my lines are being drawn. But when I insert this BeginPath() and EndPath() and StrokeAndFillPath(hDC); the nothing is being drawn.

Why it is not doing as per the expectations. I want to draw a shape for example A with a outline. And i want it to be closed when drawing is ended and filled the hollow portion.

What am I doing wrong in this ?I am not implementing it in WM_PAINT but drawing is done in WM_LBUTTONUP.

View 6 Replies View Related

C++ :: Display Last 1000 Lines From Multiple Text Files (log Files)

Jan 16, 2014

I am writing a piece of code that requires me to display the last 1000 lines from a multiple text files (log files). FYI, I am running on Linux and using g++.

I have a log file from which - if it contains more than 1000 lines, I need to display the last 1000 lines. However, the log file could get rotated. So, in case where the current log file contains less than 1000 lines, I have to go to older log file and display the remaining. For e.g., if log got rotated and new log file contains 20 lines, I have to display the 980 lines from old log file + 20 from current log files.

What is the best way to do this? Even an outline algorithm will work.

View 6 Replies View Related

Visual C++ :: How To Move Video Forward / Backward When User Drags Slider Bar

Jun 11, 2013

I am working on a project in which I use DirectShow to Play / Pause / Stop the video. I am using slider bar to show the progress of the video. As the video starts playing, the slider bar moves in proportion to the video duration. Now when user moves/drags the slider bar to a new position, I want to forward the video in equivalent proportion.

Say if video duration is 50 seconds and max range of the slider bar is set to 100. slider will 2 steps for 1 second of video progress. Now if user drags the slider to 60 while video is playing, I want to increment/forward the video. if user moves the slider backward, video should move backward.

I have done with the slider moving along with the video and when user drags the slider. How to set the new position of the video, so that the video starts playing from that point.

View 4 Replies View Related

Visual C++ :: SDI App - Constraint Mouse To Move Only Horizontal Direction If Shift Key Pressed

Apr 23, 2015

In a SDI app, I constraint the mouse to move only an horizontal direction, if "Shift" key is pressed ... here is the code:

Code:
void CTestMouseView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
// TODO: Add your message handler code here and/or call default
if(GetKeyState(VK_SHIFT) < 0) {
CRect rect;
GetWindowRect(&rect);
GetCursorPos(&m_point);

[Code] ....

Nothing complicated, and it works well ... except one thing: when I press the shift key and the mouse is moving by SetCursorPos, is moving pretty slow ... why ? I can not figure out why ! For testing, I attached the test project ...

View 13 Replies View Related

Visual C++ :: Looping Lines And Blocks Of Characters

Mar 17, 2013

I have a file that is like the following, with patterns of pipes in it:

Code:
||| || | |
| ||| | | |
|| || ||

I have to consider each row of pipe characters to be in blocks of 3 characters each (e.g. - positions 1-3, then 4-6, etc, etc...) but I have to capture all of the pipes, in sequence, like so:

positions 1-3 for lines 1-3, then positions 4-6 for lines 1-3, etc, etc...

How to get this done besides writing severely redundant control structures like loops, one after the other?

View 5 Replies View Related







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