 |

|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|

|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|

|
I am building my first real DLL. I am using DirectShow “Base Classes” library to build a custom DirectShow filter based on sample code from DirectShow SDK.However, this is not DirectShow question. I managed to build VC 6.0 DLL, however, the problem is that it builds “External Dependencies” - in this case basetsd.h taken from the original VC6.0 installation which is now hopelessly inadequate for this application. My basic question to the gurus here – what exactly is “External Dependencies” as used in MFC DLL (VC6.0) wizard? Is is similar to “additional include / library links? So far I cannot see it in command line. Any help would be greatly appreciated and if such thing exists in later MS IDE please let me know and I'll look for it there. But from my recent experience I am reluctant to download any VS after 6.0! Cheers Vaclav Addendum: Here is MSDN 2001 definition: Note The External Dependencies folder lists files that are not part of the project but that are needed to build the project. You can add a file to the project by simply dragging it from the External Dependencies folder to any of the project folders, or to any top-level project node. So, it means that "standard" "include" path is used to load the OLD "basetsd.h". I guess I'll modify the original basetsd.h to make things fly.
-- modified 15 hrs ago.
|
|
|
|

|
External dependencies in a project are normally header files that are not part of your project, but defined as part of the OS or some library.
This is different from external DLL dependencies.
For example, take the example of STL.
You could be using one of its header like algorithm.
This is an external dependency for your project.
The algorithm header internally includes several other headers recursively like xmemory, xutility, new, limits, cstdlib, exception etc.
So all these headers become external dependencies for the project.
Similarly, DirectX has its own dependencies.
Modifying an external dependency is not a good idea because one such file may be dependent on many others.
So you either upgrade to a later compiler or write all routines from scratch (Which is also not a good idea).
Also, VC 6.0 is outdated. Newer compilers are much better in terms of the error checking capabilities and the optimized output it generates.
|
|
|
|

|
getting linking error for a class which implements IMPLEMENT_RUNTIMECLASS_T macro.
|
|
|
|

|
Well unfortunately, we cannot see your screen, so have no idea what the error or its solution might be.
Use the best guess
|
|
|
|

|
- I've created a CPngButton from CBitmapButton.
- It overrides DrawItem() and draws the given PNG image using GDI+.
- The wm_erasebkgnd and wm_ctlcolor is taken care.
- while displaing the CMainFrame its displaying properly.
- Later if we resize the window couple of times, the transparent portions of button becomes black.
- OS is Windows 7 with Aero enabled.
- Screenshot is here[^]
- Any idea what I'm missing here?
(Some more information: The buttons are hosted on a CWnd as container. This CWnd is placed over left of menubar to looks like a quick access toolbar, which is a requirement).
Best Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|

|
hi all,
I am using
static char alphabet[] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
static int alphabet_size = sizeof(alphabet) - 1;
CString str_val=_T("");
void brute_impl(char * str, int index, int max_depth)
{
int i;
for (i = 0; i < alphabet_size; ++i)
{
str[index] = alphabet[i];
if (index == max_depth - 1)
{
str_val.Format("%s", str);
}
else
{
brute_impl(str, index + 1, max_depth);
}
}
}
void brute_sequential(int max_len)
{
char * buf = new char[max_len + 1];
int i=0;
while(buf[i] != NULL)
{
if(i==max_len+1)
break;
buf[i]='\0';
i++;
}
CString str=_T("");
str.Format("size of array is %d\n", i);
for (i = 1; i <= max_len; ++i)
{
memset(buf, 0, max_len + 1);
brute_impl(buf, 0, i);
}
free(buf);
}
but its time consuming and very slow
anybody have more efficient and fast method for this.
thanks.
|
|
|
|

|
Use a passwords list; you can find them freely on the web.
|
|
|
|

|
hi guys recently i started to work with open gl in dev c++ 4.9.9.2. I downloaded the glut package and all the dlls and object files. After installing it i tried a sample program. But i got lot of linker errors and it didnt run eventhough my syntax was correct. Anybody please help
|
|
|
|

|
adding only header (*.h) is not enough. You have to also add proper lib or cpp to your program in order to linker could see definitions of functions you are using in your program.
To add lib, see the linker options, there has to be some place to include additional libraries.
|
|
|
|

|
Hello,
I've just started to programm in C++, using Builder C++. I need to stablish comunication via internet between two computers. I've succed using the ClientSocket Component and the ClientServer but only if the computers are in a local network but not if the computers are in different networks. Here is my code for the server:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
//--------------------Abrir el Servidor---------------------------------------//
void __fastcall TForm1::BAbrirClick(TObject *Sender)
{
//Configurar el número de puerto
ServerSocket1->Port=StrToInt(Npuerto->Text);
//Abrir el servidor
ServerSocket1->Open();
//Actualizar estado de los botones
BAbrir->Enabled=false;
BCerrar->Enabled=true;
//Informar de que se ha abierto el servidor
BEstado->SimpleText="Servidor Conectado!";
//Indicar el número de conexionoes activas
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
//Activar el Boton de enviar mensaje
BEnviar->Enabled = true;
}
//----------------------------------------------------------------------------//
//---------------------Cerrar el Servidor-------------------------------------//
void __fastcall TForm1::BCerrarClick(TObject *Sender)
{
//Cerrar el Servicio
ServerSocket1->Close();
//Actualizar estado de los botones
BAbrir->Enabled=true;
BCerrar->Enabled=false;
//Informar del cierre del servidor
BEstado->SimpleText="Servidor Cerrado!";
//Actualizar el campo de nº de conectados
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
//Desactivar el Boton de enviar mensaje
BEnviar->Enabled = false;
}
//----------------------------------------------------------------------------//
//---------------------Cuando se Conecte un Cliente---------------------------//
void __fastcall TForm1::ServerSocket1ClientConnect(TObject *Sender,
TCustomWinSocket *Socket)
{
//Mostrar aviso en la barra de estado
BEstado->SimpleText="Conectado desde "+Socket->RemoteAddress;
//Actualizar el número de conectados
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
}
//----------------------------------------------------------------------------//
//---------------------Al Desconectarse un Cliente----------------------------//
void __fastcall TForm1::ServerSocket1ClientDisconnect(TObject *Sender,
TCustomWinSocket *Socket)
{
//Actualizar el número de conectados
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections-1);
//Informar de la desconexión
BEstado->SimpleText="Desconectado de "+Socket->RemoteAddress;
}
//----------------------------------------------------------------------------//
//---------------------Al recibir un Mensaje----------------------------------//
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
//Espacio para recibir el mensaje
char * buffer;
int len;
AnsiString Mensaje;
int i;
// Recibir mensaje
int *tam;
tam = new int;
*tam = Socket->ReceiveLength();
len=Socket->ReceiveBuf(buffer,*tam);
buffer[len]=0;
//Estructura para mostrar el mensaje correctamente
TTime hora = TTime::CurrentTime();
AnsiString MensajeIn = Socket->RemoteAddress;
MensajeIn += " A las " + TimeToStr(hora) + " Dice" "----->";
ChatBox->Lines->Add(MensajeIn +StrPas(buffer));
BEstado->SimpleText=IntToStr(len)+"Nuevo mensaje entrante!";
// Repetir el mensaje a los demás
Mensaje = StrPas(buffer);
strcpy(buffer,Mensaje.c_str());
for(i=0;i<ServerSocket1->Socket->ActiveConnections;i++)
ServerSocket1->Socket->Connections[i]->SendBuf(buffer,strlen(buffer));
delete[] buffer;
}
//----------------------------------------------------------------------------//
//--------------------Enviar un Mensaje---------------------------------------//
void __fastcall TForm1::BEnviarClick(TObject *Sender)
{
//Espacio para meter el mensaje
char buffer[256];
int i;
//Recoger el Mensaje del campo de entrada
AnsiString Mensaje = CampoMensaje->Text;
strcpy(buffer,Mensaje.c_str());
//Enviarlo a los conectados
for(i=0;i<ServerSocket1->Socket->ActiveConnections;i++)
ServerSocket1->Socket->Connections[i]->SendBuf(buffer,strlen(buffer));
//Añadirlo al Chatbox
TTime hora = TTime::CurrentTime();
ChatBox->Lines->Add("Servidor a las " +TimeToStr(hora)
+ " dice----->" + Mensaje);
}
//----------------------------------------------------------------------------//
//---------------------Borrar la Memo-----------------------------------------//
void __fastcall TForm1::LimpiarClick(TObject *Sender)
{
//Borrar
ChatBox->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CampoMensajeKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == 13)
TForm1::BEnviarClick(CampoMensaje);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NpuertoKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == 13)
TForm1::BAbrirClick(Npuerto);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TcpServer1Accept(TObject *Sender,
TCustomIpClient *ClientSocket)
{
//Configurar el número de puerto
TcpServer1->RemotePort = StrToInt(Npuerto->Text);
//Abrir el servidor
TcpServer1->Open();
//Actualizar estado de los botones
BAbrir->Enabled=false;
BCerrar->Enabled=true;
//Informar de que se ha abierto el servidor
BEstado->SimpleText="Servidor Conectado!";
//Indicar el número de conexionoes activas
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
//Activar el Boton de enviar mensaje
BEnviar->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TcpServer1CreateHandle(TObject *Sender)
{
//Actualizar el número de conectados
NOnline->Text=IntToStr(TcpServer1->Active-1);
//Informar de la desconexión
BEstado->SimpleText="Desconectado de "+TcpServer1->LocalHostName();
}
//---------------------------------------------------------------------------
How can I implement comunication (a simple chat is enough) between the two computers?
|
|
|
|

|
It is exactly the same, you just need to configure your firewalls to allow access between the two systems.
Use the best guess
|
|
|
|

|
AntonioJesus wrote: computers are in different networks
Hola Senor - I think anyone reading this would need to know how your network was set up and what exactely you mean by 'different networks' .. for example, you could mean in two different subnets/zones, or talking over the internet
In both cases, its likely your code doesnt need any change, but your networks may need routes, firewall rules etc
'g'
|
|
|
|

|
With different Newtworks I mean over the internet. Both computers are conected to internet via wi-fi both running windows.
|
|
|
|

|
As already said by others: This is not a problem of your code, but of the network topology.
The IP adress of the server must be routable (adress can be reached by the client). If the server is behind a router that connects a local network using private adresses to the internet (or another local network with a different private IP range), you must setup port forwarding on the router. If there is a firewall involved, it must be also configured to allow passing packets from/to the forwarded ports and the server IP. When internet access on the server side uses dynamic IPs (common with dial-up connectings), you must also register a dynamic DNS name and configure this in the router.
This setup is not required for clients because routers on the client side will usually perform the forwarding. But when using non-standard ports, it may be also necessary to allow these ports in firewalls and routers.
The keywords to read more about this topic are NAT (Network Address Translation), Port Forwarding, and DDNS (Dynamic DNS).
When using a private internet access, see the manual of your router to configure port forwarding and DDNS. Otherwise ask the network administrator of your company / educational institution.
|
|
|
|

|
One of the benefits of the OSI model is that applications (level 7) rarely ever have to change when the underlying hardware/protocol (layers 1-3) changes.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|

|
Hey all, I'm not sure if this is the right place for this kind of discussion but I’ll ask anyways. I’ve been working on embedded systems for a while, mainly in C. I’d like to do more with C++/.Net (or other OOP languages/frameworks etc..) but I don’t know where to start in terms of a non-embedded project. My question is; does anyone have an idea for a project or perhaps worked on something that was useful and more challenging than text book style projects (ie something more “real world” that I can use to gain OOP experience in my own time). Any thoughts would be appreciated.
|
|
|
|

|
Basically, it doesn't matter what you code, you can always choose to approach it from an OOP perspective. So, then it's just the question of what you want to create.
I often create (small) tools, math-gimmicks like prime-number searches, and 'technical test projects' (to test out a specific API/environment/library for the purpose of learning).
Others are more inclined to program games, or simulations, for instance.
I think a pitfall in this case with creating a program in C++ is that it's all too tempting to use what you know in C and do it like that (though you'll have to consider for yourself if that applies).
As soon as you have something you want to create, start thinking about the involved objects and their lifetime. Start simple, for your first project, and limit the complexity and amount of classes. Most of OOP is about dividing functionality and responsibility among classes and determining their lifetime, and modelling the interactions between them. A good strategy is to make each class responsible for exactly one thing and to use a 'black box' principle: other code/classes should only concern themselves with what the class does for them, and not 'how' it does it. A rule of the thumb related to this is that if you start writing code in class1 like class2->memberClass->someMethod() that something is wrong, because now class1 needs to know the rules of class2::memberClass, which violates that black box principle. Of course, this is only a guideline and not necessarily is wrong.
Good luck
|
|
|
|

|
Pick up Visual Studio and play around writing MFC apps. It will give you a nice into to classes, OO, UI design, and you can knock up some interesting apps.
I use MFC a lot writing test programs for my Windows drivers and is an excellent technology.
==============================
Nothing to say.
|
|
|
|

|
static int pstate_param_set(char *val, int kp)
{
return 0;
}
static int pstate_param_get(char *buffer, int kp)
{
return 0;
}
struct mystruct
{
int (*set)(char *val, int kp);
int (*get)(char *buffer, int kp);
};
static struct mystruct jober = {
.set = pstate_param_set,
.get = pstate_param_get
};
==============================
Nothing to say.
|
|
|
|
|

|
Error . then two missing ; errors
==============================
Nothing to say.
|
|
|
|

|
Good link!
I have been wandering around the net trying to find the answer. SO it seems it is a C only method of struct func pointer initialisation. Interesting.
==============================
Nothing to say.
|
|
|
|

|
Nah, doesnt work as C code with VS either.
error C2059: syntax error : '.'
And it is C code, I checked by declaring a variable after a func, it gulched at that, so it is deffinitely seeing it as C code.
==============================
Nothing to say.
|
|
|
|
|

|
Exactly: it still does not.
Veni, vidi, vici.
|
|
|
|

|
Cheers Chris, I thought that was the case.
==============================
Nothing to say.
|
|
|
|

|
So what is the specific VC compiler output?
|
|
|
|

|
error C2059: syntax error : '.'
==============================
Nothing to say.
|
|
|
|

|
ok i have a problem with MFC, i have two dialogs and an additional class, in first dialog i create an object of my custom class and set its values, now i want to pass my object to an other dialog to manipulate it, how can i do that?
|
|
|
|

|
Just rewrite the dialog contructor passing it a handle or pointer to your object.
==============================
Nothing to say.
|
|
|
|

|
im noob in this topic could you show me an example?
|
|
|
|

|
You can also chenge the information between your main application and a dialog modal in few ways, which you can see here[^], there you have some exmaples ...
|
|
|
|

|
Yesh, override the dialogs DoModal() func (ie just add a new constructor that takes the params you want.)
In your implementation of DoModal() you copy the params locally, and then call the base class DoModal().
When your other dialog or whatever creates your new dialog, it passes the required params to the DoModal() func.
MyNewDiaolog * dialog = new MyNewDialog;
dialog->DoModal();
==============================
Nothing to say.
|
|
|
|

|
It's usually not a good idea to tie the dialogs together like that. It makes them too interdependent. Instead, keep the data in the custom class and create an instance of that class in the CWinApp-derived class. Each dialog can then get access to that data using AfxGetApp().
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|

|
Returning a pointer to the app class, allowing a dialog class to access data internal to the app class does what exactly in terms of following the Object Oriented methodology?
A typical hack. That is why OO design allows for polymorphism, so that data can be passed around as required. Overriding the dialog constructor then is actually a purer OO way of acchieving what he wants.
==============================
Nothing to say.
|
|
|
|

|
I need to integrate a facebook login in my application so I want to know if there are library to add!!!!! Thanks in advance.
|
|
|
|

|
I just read an article which augues that coding with only one programming language would limit one's capability to code.
I'm a little confused about this argument, because I've always thought that, one developer proficiently mastering one language outperforms one using many language but he actually knows relatively little about each one.
So, I'm not sure whether the idea of the passage I read is very correct.
I just want to hear more opinions about this issue, so, please feel free to show your thoughts about it.
|
|
|
|

|
I suspect they're concerned about paradigms more than actual languages. If you know only imperative languages or only functional languages for instance you may have trouble solving problems that are better suited to the other paradigm. You may know several imperative languages, but you still may not easily solve problems suited to functional languages.
|
|
|
|

|
Uni-voter countered.
Make it work. Then do it better - Andrei Straut
|
|
|
|
|

|
rudiestf wrote: Actually, I feel C++ is quite limitless, because it contains three paradigms,
which are process-oriented, object-oriented and generic.
That however doesn't mean it is cost effective. So for example although you might be able to solve a problem using only C++, solving it using SQL would take far less time and thus cost less.
|
|
|
|

|
PIEBALDconsult wrote: You may know several imperative languages, but you still may not easily
solve problems suited to functional languages.
However realistically one in unlikely to encounter a problem where that matters. Especially for that specific case. But one is more likely to encounter problems such as architecture and performance.
|
|
|
|

|
If your unique programming language is C++ then you have no limits.
Veni, vidi, vici.
|
|
|
|

|
I really appriciate your opinion~ cuz I'm a big fan of c++ programming~
|
|
|
|

|
CPallini wrote: If your unique programming language is C++ then you have no limits.
Idealistically one can argue that but realistically it isn't true. An programmer that has spend 15 years writing embedded C++ controllers for hard drives probably isnt going to be as effective for creating a new web server on windows versus someone that has been doing exactly that for 8 years using C#.
And the reverse is true as well.
Businesses care about how much it will cost and when it will be delivered.
|
|
|
|

|
Being unable to create a new web server using C# is a plus, not a limit.
Of course you are right.
Veni, vidi, vici.
|
|
|
|

|
This whole argumant is misplaced. Being a good software engineer is not about the language, it is about how he solves problems. The language is just one of the tools to acchieve that goal.
==============================
Nothing to say.
|
|
|
|

|
Thanks for replying
I think your idea is right in some ways.
Indeed, a good software developer can solve many problems.
But, the more programming languages he masters, the more problems he can solve. So, in this way, the idea that "the more languages, the better" seemes to be right.
Can you still hold your opinion?
|
|
|
|
 |