|
"Y", the radius at x = 0, varies with the angle of the arc (as a point on the circumference).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Tell me if I am right I think I first need to determine the angle so if is 25 % then the angle is 90 4 / 360 then to get the y it’s y = consin(angle) x = sin(angle)
Right ?
|
|
|
|
|
|
Thanks for help one more follow up question
Would this equation not have to be multiplied by the number of pixels per circle degree I mean the formula is the same for big and small circles so you have to taken into account the size of the circle I’m sure I can do it with GetCientrect
Thanks
|
|
|
|
|
The radius determines the size of a circle. If you want to scale, you vary the radius.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
My client etc is a square so either the width or height divided by 2
Ok thanks
|
|
|
|
|
When doing drawing first you do it to memory than BitBlt to the device -> device context can to you save the memory dc to a file ?
thanks
|
|
|
|
|
|
I am writing a pie chart using pie and ellipse first doing CreateCompatableBitmap Selecting to mem dc but the example will work
thanks
|
|
|
|
|
No, as shown in the documentation at GetDC function (winuser.h) - Win32 apps | Microsoft Docs[^]:
Quote: The GetDC function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. The device context is an opaque data structure, whose values are used internally by GDI.
You need to save other information that you use to create the drawing.
|
|
|
|
|
I am writing a pie chart using pie and ellipse first doing CreateCompatableBitmap Selecting to mem dc but the example will work
Mircea provided an example that will work for me
thanks
|
|
|
|
|
ForNow wrote: Mircea provided an example that will work for me
Yes. However in this example the bitmap is saved into the file, and not the memory or some other DC (device context)!
|
|
|
|
|
The incomplete code bellow doesnt seem to be working as intended. I would be really gratefull to any help.
#include<iostream>
#include <fstream>
#include<cstring>
using namespace std;
const int N=20; <pre lang="C++"><pre lang="text"><pre lang="C++"></pre></pre></pre>
const char Filename[]= "Shiplist.dat";
struct Ship {
unsigned int number;
float capacity;
char name[50];
};
fstream sp;
int menu() {
int choice;
cout << "\n \t MENU";
cout << "\n 1. Add individual ships";
cout << "\n 2. Add a list of ships";
cout << "\n 3. Print the list of all ships on screen";
cout << "\n 4. Show the ships with the biggest load capacity ";
cout << "\n 5. Search ship by name";
cout << "\n 6. Add shipments";
cout << "\n 7. Cancel shipments";
cout << "\n 8. Save ship information";
cout << "\n 9. Add new ship to the list";
cout << "\n 10. Exit";
do {
cout << "\n Your choice:"; cin >> choice;
} while (choice<1 || choice>10);
return choice;
}
Ship input () {
Ship S= { 0 };
cin.ignore();
cout << "\n Enter ship number:"; cin >> S.number;
cin.ignore();
cout << "\n Enter the name of the ship:"; cin.getline(S.name,50);
cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity;
return (S);
}
int enter (Ship Lib[], int n) {
int i, m;
do {
cout << "\n Enter information for how many ships(max 5 in one go):";
cin >> m;
} while(m<0 || m>5);
if (n+m < 20) {
for (i= n; i<n+m; i++) {
cout << "\n Ship " << i+1;
Lib[i]= input();
}
return (n+m);
} else cout << "\n You can't add any more ships!";
}
void Save_File (Ship Lib[], int n) {
sp.open(Filename, ios::binary | ios::out);
if (!sp) { cout << "\n Error in file! \n"; exit(1); }
sp.write((char*)Lib, sizeof(Ship) * n);
sp.close();
}
void append () {
Ship b= { 0 };
sp.open(Filename, ios::binary | ios::app);
if (!sp) { cout << "\n Error in file! \n"; exit(1); }
cout << "\n Add a new ship to the list \n";
b= input();
sp.write((char*)&b, sizeof(Ship));
sp.close();
}
void output (Ship Lib[], int n) {
int i, k=0;
cout << "\n \t List of all ships \n";
for (i=0; i<n; i++) {
cout << "\n" << i+1 << "\t" << Lib[i].number << " " << Lib[i].name << " " << Lib[i].capacity ;
k++; if(k % 5 == 0) cout << "\n\n\n\n\n\n";
}
}
int Load_File (Ship Lib[]) {
long pos; int n=0, i; Ship b;
sp.open(Filename, ios::binary | ios::in);
if (!sp) { cout << "\n File doesn't exist!! \n"; return n; }
sp.seekg(0L, ios::end);
pos= sp.tellg();
sp.close();
n= pos/ (sizeof(Ship));
sp.open(Filename, ios::binary | ios::in);
if (!sp) { cout << "\n Error in file! \n"; exit(1); }
for (i=0; i<n; i++) {
sp.read((char*)&b, sizeof(Ship));
Lib[i]=b;
}
sp.close();
return n;
}
void Ship_by_Name (Ship Lib[], int n) {
char Sname[50];
cin.ignore();
cout << "\n Ship name: ";
cin.getline(Sname, 50);
for (int i = 0; i < n; i++)
if (!strcmp(Sname, Lib[i].name)) {
cout << "\n Ship found!";
cout << "\n Number: " << Lib[i].number << "\t Name: " << Lib[i].name << "\t Load capacity: "
<< Lib[i].capacity;
break;
} else cout << "\n This ship isn't recorded!";
}
int main () {
int choice, n=0;
Ship Lib[N];
char answ= 'y';
n= Load_File(Lib);
do {
choice= menu();
switch (choice) {
case 1: input(); break;
case 2: n= enter(Lib, n); Save_File(Lib, n); break;
case 3: n= Load_File(Lib); output(Lib, n); break;
case 5: n= Load_File(Lib); Ship_by_Name(Lib, n); break;
case 8: Save_File(Lib, n); break;
case 9: do {
append(); n++;
cout << "\n One more[y/n]? " << "\n Answer: "; cin >> answ;
Save_File(Lib, n);
} while (!(answ == 'N' || answ == 'n')); break;
}
} while (choice != 10);
}
|
|
|
|
|
This kind of thing is usually posted as a question. On the menu bar just under the site banner, click on quick answers/Ask a Question.
However, "doesn't seem to be working as intended" tells us nothing about what your code is trying to do, and no one is going to waste time trying to guess. You have to provide more details if you want an answer.
|
|
|
|
|
Ship input () {
Ship S= { 0 };
cin.ignore();
cout << "\n Enter ship number:"; cin >> S.number;
cin.ignore();
cout << "\n Enter the name of the ship:"; cin.getline(S.name,50);
cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity;
return (S);
}
It will help get a quicker answer if your code is properly indented, and uses the correct <pre> tags as above.
|
|
|
|
|
panda08 wrote: The incomplete code bellow.... If you completed, would it then work?
panda08 wrote: The incomplete code bellow doesnt seem to be working... Was it intentional that you failed to explain what it is (not) supposed to do?
panda08 wrote: ...as intended. What is its intent?
The onus is on you to pare down your code to just that which is problematic; not ours to wade through a bunch of code to try and figure out what it is supposed to do and why it is not doing such.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi
I have been trying to write to the non client area of a window specifically a Cdialog
This CDialog has a Rich Edit (I am displaying storage obtained) and I am trying to give details about it in the Non client area
seems to me there are 3 choices if I want to make it look nice nice means using the CDC class
1) process the ON_WM_NcPaint 2) using windows desktop manager (extending the frame and making it the client area) 3) using a static control / window
was wondering if someone could guide on which path to take
thanks
|
|
|
|
|
ForNow wrote: This CDialog has a Rich Edit (I am displaying storage obtained) and I am trying to give details about it in the Non client area
What kind of "details" are you gong to give in the dialog titlebar ("Non client area")? And why the simple SetWindowText call could not help you?
Or did you mean some other area (not a titlebar - ?) to put your details?
|
|
|
|
|
I am displaying MainFrame storage sent via TCP/IP sockets to Windows so the rich edit would display the actual storage
The data in the NC frame of the dialog would be the storage subpool where the storage was obtained, the storage key, whether the storage fetch protect (non readable) owning tcb in z/os resources are owned by the task represented by a tcb control that have programs represented by RB (request blocks)
as anside one of the things I learned that in windows that are only process and threads
thanks
|
|
|
|
|
ForNow wrote: I am displaying MainFrame storage sent via TCP/IP sockets to Windows so the rich edit would display the actual storage
In the context of your question it doesn't matter where the data you are going to display is coming form and how.
however, you didn't answer why the simple SetWindowText cannot be used nor did you described the format of the data to be desplayed in NC area.
|
|
|
|
|
let me preface this by saying I am basically a mainfame programer so then I appreciate your expertise so here goes
SetTextWindow gives me one line to fill out with no choice for color background color or font
If I for instance use an ownerdraw static window my OnDrawitem could handle an rcItem Rect with possibly multiple lines allowing me to have my own font and color ?
|
|
|
|
|
Then what does prevent you to implement some user defined control (derived from CStatic or, better, from CWnd), place it above or below your RichEdit and draw what you want using CDC class in this control?
Just try it! Then if you wouldn't happy with such implementation then your next step were to move the code to the OnNcPaint handler.
|
|
|
|
|
thanks BTW I spent hours and hours with NCPAINT is doesnt work after getting the right DC GetWindowDC did a Textout pos 1,1 and text was never displayed
anyway thanks for your help much appreciate it
|
|
|
|
|
Make sure you are using the correct DC. Windows loves to clip stuff when drawing.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
I did a quick searchereno using what we use, Lucene.net, and it's query syntax, and obtained:
XFontDialog - Customizing CFontDialog Part I: Adding Font Filters[^]
If you scroll down to the end of the page where the last image is perfunctorily displayed perhaps you'll see what I saw and think Is this what a non-client area customization looks like?
|
|
|
|