|
|
Well, it is high time that you set up breakpoints and start debugging.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I have a problem when I set the text of a static text control. I do it with this code:
TCHAR buffer[sizeOfBuffer];
..............................
m_ProgressText.SetWindowText(buffer);
But the static control displays the text up to a point and many squares after that. The text might have newlines, but I don't know if that's the problem.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
can you show your code for initializing the contents of buffer variable
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
I get it from a file (a pipe actually) with ReadFile. It comes as ASKII text, which I then convert to Unicode and pass to SetWindowText.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I just checked and it turned out ReadFile doesn't terminate the string, so the problem is solved
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I guessed the problem would be with populating the buffer ...
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
MFC, STUDIO 2008, MDI-project
Christ has arisen!
There are 2 classes:
class CADO_MDIView : public CscrollView
class CAdodc_MDI : public Cdialog
В class CADO_MDIView имеем
CString m_s5(“YYYYYYYYYYY”);
MessageBox(m_s);
// ADO_MDIView.cpp : implementation of the CADO_MDIView class
#include "stdafx.h"
#include "ADO_MDI.h"
#include "ADO_MDIDoc.h"
#include "CntrItem.h"
#include "ADO_MDIView.h"
#include "Adodc_MDI.h"
// Adodc_MDI.cpp : implementation file
#include "stdafx.h"
#include "ADO_MDI.h"
//-1 #include "ADO_MDIView.h"
#include "Adodc_MDI.h"
//-3 #include "ADO_MDIView.h"
CADO_MDIView dlg_View; // adodc_mdi.cpp(211)
dlg_View.m_s5;
--------------------------------------
ado_mdiview.h(23) : error C2143: syntax error : missing ';' before '*'
ado_mdiview.h(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
ado_mdiview.h(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
ado_mdiview.h(23) : warning C4183: 'GetDocument': missing return type; assumed to be a member function returning 'int'
adodc_mdi.cpp(211) : error C2248: 'CADO_MDIView::CADO_MDIView' : cannot access protected member declared in class 'CADO_MDIView'
ado_mdi\ado_mdiview.h(18) : see declaration of 'CADO_MDIView::CADO_MDIView'
ado_mdi\ado_mdiview.h(15) : see declaration of 'CADO_MDIView'
--------------------------------------
// Attributes
public:
CADO_MDIDoc* GetDocument() const; // ado_mdiview.h(23)
--------------------------------------
class CADO_MDIView : public CScrollView
{
protected: // create from serialization only
CADO_MDIView(); // ado_mdi\ado_mdiview.h(18)
|
|
|
|
|
Well, you have errors in your ado_mdiview.h . What else?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I have two applications running in parallel.I want to know the events generated in one application (because of
user's action on dialog controls)in the other application.
Those two applications are not communicating with each other directly.But the second application has the info of
dialog control ID's of the first application.
Is it possible to know the events generated in other application.?
Please tell me how can I do it.
Regards,
Sunil Kumar
|
|
|
|
|
sunilkumar.d wrote: Is it possible to know the events generated in other application.?
Well, yes - Spy++ can do it.
I suspect you need to create a global Windows hook that gets injected into the first application which can send information to the second one.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
Thanks for the reply.
Can I get any detailed info on how to do this?
Regards,
Sunil Kumar
|
|
|
|
|
Try this article[^] - CP has lots of useful articles that are just a search away - learn how to use the resources you have available to you - at your fingertips!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi guys,
I have a following problem. I'm trying to read a range of data information from the following .dat file specified below.
I'm using the ifStream to read in the data from the Info.dat file. I have created the Student class object S[4], then using it to set the data that I've read in using variables. It is also a need for while loop to be used in the program. However, the problem is that it does not work out well.
My intended output is as such:
output:
------------
Alan <br />
no of subjects taken: 4<br />
no of passes :3<br />
total credits : 17 and so on.
Really appreciate the help.
Info.dat
Alan English 4 F Maths 3 P Science 5 P Geo 5 P
Danny English 2 P Maths 3 P Science 4 P Geo 2 P
Jane English 1 F Maths 3 F Science 3 P Computing 8 P
Keith English 5 P Maths 3 P Science 5 P Literature 4 P
int main()<br />
{<br />
Student S[4];
<br />
<br />
int count, credits, totalCred;<br />
string stud, module;<br />
char pass;<br />
<br />
int Cols;<br />
int Rows; <br />
<br />
Cols = 0;<br />
Rows = 0;<br />
<br />
<br />
count = 0;<br />
totalCU = 0;<br />
<br />
ifstream inFile;<br />
<br />
inFile.open("Info.dat");<br />
<br />
if (inFile.fail()){<br />
cout<<"ERROR: File cannot be opened!"<<endl;<br />
getchar();<br />
exit(1);<br />
}<br />
<br />
<br />
if (inFile.good()){<br />
<br />
<br />
<br />
while (Rows < 4){<br />
<br />
inFile>>stud;<br />
<br />
<br />
S[Rows].setName(stud); <br />
<br />
<br />
while (Cols < 4){ <br />
inFile >>module>>credits>>pass;<br />
<br />
S[Rows].setCode(module, Cols);<br />
...<br />
<br />
if (pass == 'P'){<br />
count++;<br />
}<br />
<br />
totalCred = totalCred + credits;<br />
<br />
Cols++;<br />
}<br />
<br />
<br />
S[Rows].setCount(count);<br />
<br />
<br />
<br />
<br />
<br />
<br />
Rows++;<br />
<br />
<br />
}<br />
}<br />
<br />
inFile.close();
DA: http://www.pohcbsonic.deviantart.com/
Blog: http://www.pohcbsonicx.blogspot.com/
Homepage: http://www.pohcbsonic.tripod.com/
modified on Tuesday, April 21, 2009 12:42 AM
|
|
|
|
|
pohcb_sonic wrote: if (pf == 'P'){
What is pf ? Where is it assigned a value?
pohcb_sonic wrote: totalCU = 0;
Where is this declared?
pohcb_sonic wrote: S[Cols].setCode(module, Cols);
Shouldn't this be:
S[Rows].setCode(module, Cols); pohcb_sonic wrote: while (Cols < 4)
When does Cols ever get reset so that this while() loop can run again for the next student?
pohcb_sonic wrote: totalCred = totalCred + credits;
Does totalCred accumulate for all four students?
What does your code do if more students are added, or a student adds/drops a class? Hint: it won't work.
All that aside, is your intent to do this in C using a few C++ objects, or create your own C++ classes and use the STL?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
ok, let me re-edit the question. =) please refer to the above question again.
DA: http://www.pohcbsonic.deviantart.com/
Blog: http://www.pohcbsonicx.blogspot.com/
Homepage: http://www.pohcbsonic.tripod.com/
|
|
|
|
|
pohcb_sonic wrote: My intended output is as such:
But what is the actual output? Have you stepped through the code using the debugger?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
The output I got is:
Alan English 4 F Maths 3 P Science 5 P Geo 5 P <br />
Danny English 2 P
which I think, is not correct.
I did use the debugger to step through, and what I got was that the stud variable only captures "Alan" and not "Danny". "Danny" was being received among the inFile >>module>>credits>>pass; portion.
DA: http://www.pohcbsonic.deviantart.com/
Blog: http://www.pohcbsonicx.blogspot.com/
Homepage: http://www.pohcbsonic.tripod.com/
|
|
|
|
|
pohcb_sonic wrote: I did use the debugger to step through...
And what did you notice about Cols as soon as "Danny" was read into stud ? Go back and re-read the questions in my first post. They give big clues as to what is wrong.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
I was wondering if anyone can help me convert my Graph Code I have in Java to C++. I have going at it for a week or so now and am having trouble. Any help would be appreciated. I will post all parts of the code that is involved for this code.
Also, I will post the assignment I have and if it's easier to just ignore everything I have and do it all from scratch then I will post what is needed and said in the assignment.
import java.io.*;
public class VNode {
private VNode next;
private int vertex;
public VNode() {
next = null;
vertex = 0;
}
public VNode (int a, VNode n) {
a = 0;
next = n;
}
public VNode getNext() {
return next;
}
public int getVertex() {
return vertex;
}
public void setNext(VNode ND) {
next = ND;
}
public void setItem(int IT) {
vertex = IT;
}
}
public class Graph {
private int [] ppath;
private VNode [] Vertices;
private boolean [] visited;
private boolean setVisited = false;
private VNode a;
private VNode previous;
private VNode b;
private VNode c;
private VNode prev;
//Sets up a graph with n vertices 0,1,...,n-1
public Graph(int n) {
Vertices = new VNode[n];
for (int i = 0; i < Vertices.length; i++) {
Vertices[i] = null;
}
}
//Inserts edge(i,j). Check bounds.
public void insert(int i, int j) {
if(Vertices[j] == null) {
Vertices[j] = new VNode(i, null);
}
else if(i < Vertices[j].getVertex()) {
a = Vertices[j];
Vertices[j] = new VNode(i, a);
}
else {
a = Vertices[j];
previous = null;
while(a != null) {
if(i < a.getVertex()) {
previous.setNext(new VNode(i,a));
break;
}
previous = a;
a = a.getNext();
}
if(a == null) {
previous.setNext(new VNode(i, null));
}
}
if(Vertices[i] == null) {
Vertices[i] = new VNode(j, null);
}
else if (j < Vertices[i].getVertex()) {
b = Vertices[i];
Vertices[i] = new VNode(j, b);
}
else {
c = Vertices[i];
prev = null;
while(c != null) {
if(j < c.getVertex()) {
prev.setNext(new VNode(j, c));
break;
}
prev = c;
c = c.getNext();
}
if (c == null) {
prev.setNext(new VNode(j, null));
}
}
}
//Returns a string representing a graph using set notation.
public String toString() {
String v = "V = {";
String e = "E = {";
int vertCount = 0;
//Prints out the vertices
for (int i = 0; i < Vertices.length; i++) {
v += vertCount;
if (vertCount == Vertices.length-1) {
v += "}";
}
else {
v += ", ";
}
vertCount++;
}
System.out.println(v);
//Prints out the edges
/*int edgeCount = 0;
for (VNode n = Vertices[0]; n != null; n = n.getNext()) {
while (n.getNext() != null) {
if (edgeCount == Vertices.length-1) {
e += "}";
}
else {
e += ", ";
}
}
edgeCount++;
} */
return (v + e);
}
//Returns a string representing the graph as an adjacency list.
public String getAdjList() {
String x = "";
for (int i = 0; i < Vertices.length; i++) {
VNode adj = Vertices[i];
System.out.println(adj);
x = i + ": ";
while (adj != null) {
if (adj.getNext() == null) {
x += adj.getVertex() ;
}
else {
x += ", ";
}
adj = adj.getNext();
}
}
return x;
}
//Performs a recursive depth first search starting at k.
//Print nodes in dfs order. Use least numbered vertex scheme.
public void dfs(int k) {
if(!setVisited) {
visited = new boolean[Vertices.length];
for (int i = 0; i < visited.length; i++) {
visited[i] = false;
}
setVisited = true;
}
depthFirstSearch(k);
}
//From dfs. Actually does the searching and printing.
//The dfs just initialized the visited array.
public void depthFirstSearch(int k) {
System.out.println("K = ");
visited[k] = true;
for (VNode n = Vertices[k]; n != null; n = n.getNext()) {
if(!visited[n.getVertex()]) {
visited[n.getVertex()] = true;
System.out.print(n.getVertex());
depthFirstSearch(n.getVertex());
}
}
}
//Performs a breadth first search using a queue.
//Prints nodes in bfs order. Use least numbered vertex scheme.
public void bfs(int k) {
visited = new boolean[Vertices.length];
Queue q = new Queue();
for (int i = 0; i < Vertices.length; i++) {
visited[k] = true;
}
q.enqueue(k);
while(!q.isEmpty()) {
int w = (Integer)q.dequeue();
System.out.println("The value of w = " + w);
for (VNode n = Vertices[w]; n != null; n = n.getNext()) {
if (!visited[n.getVertex()]) {
visited[n.getVertex()] = true;
q.enqueue(n.getVertex());
}
}
}
}
//Returns the shortest path between r and s.
//If no such path exists, return null.
public int[] shortestPath(int r, int s) {
visited = new boolean[Vertices.length];
Queue q = new Queue();
ppath = new int[Vertices.length];
for (int i = 0; i < Vertices.length; i++) {
visited[r] = true;
}
//Initializes all entries in ppath to -2.
for (int a = 0; a < ppath.length; a++) {
ppath[a] = -2;
}
q.enqueue(r);
ppath[r] = -1;
while(!q.isEmpty()) {
int w = (Integer)q.dequeue();
System.out.println("The value of w = " + w);
for (VNode n = Vertices[w]; n != null; n = n.getNext()) {
if (!visited[n.getVertex()]) {
visited[n.getVertex()] = true;
ppath[n.getVertex()] = w;
q.enqueue(n.getVertex());
}
}
}
int y = 0;
int z = s;
return null;
}
}//end of Graph Class
So that is the java code.
Here is the assignment asked.
//struct Edge { int v1, int v2, int weight; }
//weight of -1 = no weight
void initGraph(int n, bool directed);
//may be a constructor - intialize a graph with n verticies
//the graph will be directed if directed is set to true
void addEdge(Edge edge)
//add an edge to the graph
int getAdjacentList(int v, List& adjList){
//puts in adjlist the vertices adjacent to v
//returns # vertices in adjlist
}
int getEdgeList(List& edgeList){
//puts in edgeList the list of edges in the graph
//for undirected graph, only 1 copy of the edge is needed
//returns # edges in edgeList
}
bool isPath(int start, int end, List& path){
//returns true if there is a path from start to end
//use Depth-First search algorithm (a private method)
//puts in path the list of vertices on the path from
// start to end (if there is a path)
}
Thanks for all and any help.
|
|
|
|
|
NxtGr8One wrote: I will post all parts of the code that is involved for this code.
[sarcastic]As opposed to just one piece at a time? Thanks.[/sarcastic]
NxtGr8One wrote: public class VNode {
private VNode next;
private int vertex;
public VNode() {
next = null;
vertex = 0;
}
Something like:
class VNode
{
private:
VNode *next;
int vertex;
public:
VNode()
{
next = NULL;
vertex = 0;
}
VNode( int a, VNode *n )
{
a = 0;
next = n;
}
VNode* getNext( void )
{
return next;
}
}; I trust you can attempt the rest.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Is it possible to have a C++ program work only if it is within a certain directory, say.. C:\Program Files\Random Folder ?
If so, any tips as to what code I would use?
|
|
|
|
|
Use _getcwd() or GetCurrentDirectory() and check the results.
PS. The comment below to use GetModuleFileName(NULL, ...) is the right answer. You can then compare the string using lstrcmpi(), the Win32 CompareString() function or something similar.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
modified on Tuesday, April 21, 2009 11:18 AM
|
|
|
|
|
#include <direct.h> // for getcwd
#include <stdlib.h>// for MAX_PATH
#include <windows.h>
#include <iostream> // for cout and cin
using namespace std;
// function to return the current working directory
// this is generally the application path
void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}
int main()
{
// _MAX_PATH is the maximum length allowed for a path
char CurrentPath[_MAX_PATH];
// use the function to get the path
GetCurrentPath(CurrentPath);
// display the path for demo purposes only
char temp[_MAX_PATH];
char temp1[_MAX_PATH]={"C:\\Program Files"};
if(CurrentPath==temp1){
cout << CurrentPath << endl;
cout << temp1 << endl;}
cout << "Press Enter to continue";
cin.getline(temp,_MAX_PATH);
return 0;
}
Thats what I have, and it outputs the current path and what temp1 holds when the if statement is gone, but no matter what I cannot get the program to check if its in the right directory. Any more tips?
|
|
|
|
|
gamefreak2291 wrote: if(CurrentPath==temp1){
You should be using some sort of string compare routine here (e.g., strcmp() ).
Have you used the debugger to step through the code?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|