|
thekeralite wrote: is it possible to publish my cpp program code in this website ? does the code have to meet some specifications/standard ? how do i submit it ?
Please see our Submission Guidelines[^]
|
|
|
|
|
Hello,
I am making a windowed application and need the program to sit in a loop waiting to receive messages. I am having some trouble with the thread. Here is the code I have now...
Form1 * messageThread;
messageThread = new Form1;
ThreadStart * pThread = new ThreadStart(messageThread, &Form1::messageLoop);
Thread *oThread = new Thread(pThread);
oThread->Start();
This code compiles fine, but I don't think it works correctly. This is my first experience with threads, so I would appreciate any input. This code is executed when a button is clicked. I want it to call the messageLoop function, which is in Form1. When the thread receives a message, I want it to output it to the gui - but it does not do this. Any thoughts?
Roy K
|
|
|
|
|
|
Is it possible to create a thread in the class of the function that you want to call? That sounds confusing... I want to create a thread in my Form1 class so it can call the messageLoop function, which is in the Form1 class. I thought that is what this code did,
Form1 * messageThread;
messageThread = new Form1;
ThreadStart * pThread = new ThreadStart(messageThread, &Form1::messageLoop);
Thread *oThread = new Thread(pThread);
oThread->Start();
but i was wrong...
-- modified at 18:08 Tuesday 3rd January, 2006
Scratch that...stupid mistake
the code should look like the following if I wanted a change to be visible on the gui...
ThreadStart * pThread = new ThreadStart(this, &Form1::messageLoop);
Thread *oThread = new Thread(pThread);
oThread->Start();
I used the current class instance ('this') instead of creating a new class instance. This showed the changes to the gui that was running.
thanks for the help
|
|
|
|
|
// CR - carriage return
// LF - line feed
// In "cpp.properties", any new line is set as CRLF, but when the text document has been written to "bbb.txt", CRCRLF appears in "bbb.txt" instead of CRLF. Can anyone please tell me where the problem lies in?
#include <iostream>
#include <fstream>
#include <windows.h>
typedef unsigned short int usint;
int main(usint arg, char *parameter[]) {
if (arg == 2) {
using namespace std;
ifstream::pos_type size;
char *memblock;
const char *convert;
string search = "command.build.*.cpp=M:/Dev-Cpp/bin/g++.exe -o \"$(FileName)\" \"$(FileName).$(FileExt)\"";
string link_file = " -Xlinker ";
link_file += parameter[1];
string filebuffer;
ifstream readfile ("M:/SciTE/cpp.properties", ios::in|ios::binary|ios::ate);
if (readfile.is_open()) {
size = readfile.tellg();
memblock = new char [size];
readfile.seekg (0, ios::beg);
readfile.read (memblock, size);
readfile.close();
filebuffer = memblock;
delete []memblock;
filebuffer.insert((filebuffer.find(search, 0) + 93), link_file);
ofstream writefile("M:/bbb.txt");
if (writefile.is_open()) {
writefile << filebuffer;
writefile.close();
system("M:/bbb.txt");
}
else {
MessageBox (NULL, "Unable to WRITE file.", "ERROR", MB_OK);
goto end;
}
}
else {
MessageBox (NULL, "Unable to READ file.", "ERROR", MB_OK);
goto end;
}
end: return 0;
}
}
-- modified at 20:50 Monday 2nd January, 2006
|
|
|
|
|
This question should be posted in the Visual C++[^] forum. This is the C++/CLI forum that's dedicated to the new managed and mixed-mode compiler available in VC++ 2005.
|
|
|
|
|
|
I would like to use Win API's SendMessage( wnd, WM_GETTEXTLENGTH, 0, 0 );, or PostMessage function to be able to get the text from the textbox of another program. Let's say, I would like to be able to get the text from Instant Messenger and show it in my App. Does anyone know how to do this!
I'm doing it in C#, but I'm posting here because those functions are not C# native and you are more familiar with them than C# programmers.
|
|
|
|
|
In C++, you only need to include the required head file and call the API. In other languages like VB/C#, you need to use P/Invoke. Read up on using P/Invoke with VB/C# and you should be able to figure out how to do it.
|
|
|
|
|
Hi,
I have 2 LAN's and both have diffrent ip classes. On both networks people use to chat on same software. but i cann't run that software for both networks.
how can i run 2 copies of same software.
|
|
|
|
|
Your question is not very clear. And in any case, this is not the correct forum for such questions. This should be posted in the Visual C++[^] forum. This is the C++/CLI forum that's dedicated to the new managed and mixed-mode compiler available in VC++ 2005.
|
|
|
|
|
I am trying to convert a program from C++ to MC++ and it uses the following type of class arrays. Can someone show me how I would convert this tp MC++.
Thanks in advance for your help.
GlobalVariables.cpp
#include CData
CData Data[100][10];
CData.h
CData Data
{
deque<float> data1;
int data2[20];
}
CData.cpp
x = Data[10][10].data1[1]+Data[10][10].data2[4];
|
|
|
|
|
I presume that you are using VC++ 2003. If that's correct, see my article on using arrays in MC++
Using managed arrays[^]
But, if you are using VC++ 2005 and the new C++/CLI syntax, see my C++/CLI article :-
Arrays in C++/CLI[^]
|
|
|
|
|
|
Wrong forum, Brian.
This announcement should be posted in the Visual C++[^] forum. This is the C++/CLI forum that's dedicated to the new managed and mixed-mode compiler available in VC++ 2005.
|
|
|
|
|
Nishant Sivakumar wrote: Wrong forum, Brian.
My apologies. In an attempt to correct this action, I have removed my post from this forum.
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
|
|
|
|
|
Brian Hart wrote: My apologies. In an attempt to correct this action, I have removed my post from this forum.
No worries
|
|
|
|
|
HI,
i want to call a hook function to a particular window . when the window is activated then hook function must be called. If the window is disabled then we have to unhook the keyboard.
PLZ iam trying for this from longtime...........
PLZ if let me know the solution to this with the help of you..........
pradpb999@gmail.com
pradeep kumar
|
|
|
|
|
This question should be posted in the Visual C++[^] forum. This is the C++/CLI forum that's dedicated to the new managed and mixed-mode compiler available in VC++ 2005.
|
|
|
|
|
hello folks!
I'm new in c++ and I'm trying to write a c++ jpeg edge detector for linux, but I have some problems with the pixel matrix that I must use to apply the prewitt mask...
can somebody help me? how can I get one pixel grey level? how can I copy this to a matrix?
Here is my code:
#include <iostream>
#include <cstring>
#include "pic_jpeg.h"
#include "gaussian_filtering.h"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
PIC_JPEG jpg_in;
int dim_x,dim_y,d;
DYNAMIC *buffer_jpg_in;
int m_x, m_y ;
char nom_in[256];
sprintf(nom_in, argv[1]);
jpg_in.read(nom_in);
dim_x=jpg_in.getWidth();
dim_y=jpg_in.getHeight();
d=jpg_in.getDepth();
buffer_jpg_in=jpg_in.getBody();
DYNAMIC *m[512][512];
for(m_y=0; m_y<dim_y; m_y++){
for(m_x="0;" m_x<dim_x;="" m_x++){
m[m_y][m_x]="buffer_jpg_in;
}
}
fprintf(stdout,"(%d,%d,%d)\n",dim_x,dim_y,d);
PIC_JPEG" jpg_out(dim_x,dim_y,d);
dynamic="" *buffer_jpg_out;
buffer_jpg_out="jpg_out.getBody();
Gaussian_Filtering" filter(="" 4.0,="" buffer_jpg_in,="" buffer_jpg_out,="" dim_x,="" dim_y,="" d);
filter.xy_smoothing();
char="" nom_out[256];
sprintf(nom_out,="" "test_out_%s",nom_in);
jpg_out.write(nom_out,100);
="" return="" 1;
}
="" =="===========pic_jpeg
#ifndef" pic_jpeg_h
#define="" pic_jpeg_h
#include="" <iostream="">
extern "C" {
#include <string.h>
#include <stdio.h>
#include <jpeglib.h>
#include <setjmp.h>
}
#define IN(bi,bs,valeur) (((bi <= valeur) && (valeur <= bs)) ? 1 : 0)
#define DYNAMIC float
class PIC_JPEG
{
protected:
unsigned int height, width, depth;
DYNAMIC *body;
char *file_name;
int readJpeg(char *);
public:
static const unsigned int RED = 0;
static const unsigned int GREEN = 1;
static const unsigned int BLUE = 2;
static const unsigned int RGB_DEPTH = 3;
PIC_JPEG();
PIC_JPEG(const PIC_JPEG &i);
PIC_JPEG(int dx, int dy, int d);
PIC_JPEG(char *filename,DYNAMIC *buff,int dx,int dy,int d);
~PIC_JPEG();
unsigned int isLoaded() const;
unsigned int getWidth() const;
unsigned int getHeight() const;
unsigned int getDepth() const;
DYNAMIC *getBody() const; // Pas de copie
DYNAMIC &operator() (unsigned int x, unsigned int y, unsigned int d) const;
char *getFilename();
void clear();
void rescale(unsigned int w, unsigned int h);
int crop(unsigned int,unsigned int,unsigned int,unsigned int);
int read(char *filename);
int write(char *filename, int quality) const;
};
#endif
//=================gaussian filter
#ifndef GAUSSIAN_FILTERING_H
#define GAUSSIAN_FILTERING_H
#include <iostream>
#include "pic_jpeg.h" // pour DYNAMIC
class Gaussian_Filtering
{
protected :
float sigma;
DYNAMIC *buffer_in,*buffer_out;
int dim_x,dim_y,dim_z;
int depth;
int px,py,pz;
double pos_num_x[4],neg_num_x[4],den_x[4];
double pos_num_y[4],neg_num_y[4],den_y[4];
double pos_num_z[4],neg_num_z[4],den_z[4];
void init(DYNAMIC *,DYNAMIC *,int,int,int);
void coeff(int,float,double *,double *,double *);
void filtre(DYNAMIC *,int,double *,double *,double *);
DYNAMIC *extract_suite(DYNAMIC *,int,int,int);
void remplit(DYNAMIC *,DYNAMIC *,int,int,int);
int filter(float,int,int);
public :
// Initialisations
Gaussian_Filtering(float s);
void setBuffers(DYNAMIC *b1,DYNAMIC *b2,int nb_col,int nb_lig,int d);
void setBuffers(DYNAMIC *b1,DYNAMIC *b2,int nb_col,int nb_lig);
Gaussian_Filtering(float s,DYNAMIC *b_in,DYNAMIC *b_out,int nb_col,int nb_lig,int d);
Gaussian_Filtering(float s,DYNAMIC *b_in,DYNAMIC *b_out,int nb_col,int nb_lig);
// Les outils de filtrage
void xy_smoothing(); // lissage en x et y
void x_derivative(); // derivee 1ere en x lissage en y
void xx_derivative(); // derivee 2eme en x lissage en y
void xxx_derivative(); // derivee 3eme en x lissage en y
void y_derivative(); // derivee 1ere en y lissage en x
void yy_derivative(); // derivee 2eme en y lissage en x
void yyy_derivative(); // derivee 3eme en y lissage en x
void xy_derivative(); // derivee 1ere en x derivee 1ere en y
void xxy_derivative(); // derivee 2eme en y derivee 1ere en x
void xyy_derivative(); // derivee 2eme en x derivee 1ere en y
};
#endif
from paris
|
|
|
|
|
This question should be posted in the Visual C++[^] forum. This is the C++/CLI forum that's dedicated to the new managed and mixed-mode compiler available in VC++ 2005.
|
|
|
|
|
Hello,
Can I use the Windows Image Acquisition automation layer with MC++? I have looked for an answer everywhere, but could not find one. If the answer is yes, does anyone know of any good tutorials for MC++ and WIA?
Thanks, Roy
|
|
|
|
|
found it out -> yes it can here is a sample of the code to setup a webcam...
//Main Windows Image Acquisition Variables
WiaVideoClass* wiaVideo = new WiaVideoClass();
ItemClass* item;
String* selectedID;
WiaClass* wiaManager = new WiaClass();
CollectionClass* wiaObjects;
//Device specific variables
Object* device;
String* devName; //holds the name of the device
* * *
//Finds the WIA device
for(int i = 0; i < wiaManager->Devices->Count; i++)
{
//loads the wia information from the devices in the wiaManager into wiaObjects so the
// devices can be accessed
wiaObjects = dynamic_cast<collectionclass*>(wiaManager->Devices);
//accesses one of the wia deceives in the wiaObjects variable
device = wiaObjects->get_Item(i);
//passes the device by reference to wiaManager to create the WIA item
// this return value of the created item is type casted from ItemClass to item
item = dynamic_cast<itemclass*>(wiaManager->Create(&device));
//gets the device info in the object datatype and returns it, it is typecasted to a string
selectedID = dynamic_cast<string*>(item->GetPropById( (WiaItemPropertyId) WiaDeviceInfoPropertyId::DeviceInfoDevId ));
//get the webcam name
devName = dynamic_cast<string*>(item->GetPropById( (WiaItemPropertyId) WiaDeviceInfoPropertyId::DeviceInfoDevName ));
}
//some standard error messages / protection from crashing
if(selectedID == "")
{
//problem
}
else
{
//no problem
}
-- modified at 19:48 Thursday 29th December, 2005
i forgot, make sure you reference the window image acquisition com and the wia video com too
|
|
|
|
|
I am just starting to learn C++ and I need help with line code that will produce an animated bitmap. I've tried several tutorials from this website and none of them would even compile. I'm using the free BloodShed Dev-C++ Version 4.9.9.0 that I downloaded from www.download.com
I'm into learning not stealing, so if you have a little time to show me a few genereic codes that I can use that would be great.
wow. this is the coolest of the cool.....est.
|
|
|
|
|
adamx20 wrote: I'm using the free BloodShed Dev-C++ Version 4.9.9.0 that I downloaded from www.download.com
Does BLOODSHED support MFC.
I think only SDK is supported by Blood.
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|