|
*I* know that... though I'd recommend using MAX_INT...
But I was trying to lead the obviously a homework question in the right direction.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi
In my MFC dll I have this code in function:
HINSTANCE hInstance = AfxFindResourceHandle(MAKEINTRESOURCE(iID), RT_RCDATA);
return ::PlaySound(MAKEINTRESOURCE(iID), hInstance, SND_RESOURCE | SND_ASYNC | SND_NODEFAULT);
wave file is in resource of the dll, but when I call it from the exe, it can't play it, because it can not find it, (there is no RT_WAVE type!)
how can I play a wave file that is in a dll file?
Thanks
www.logicsims.ir
|
|
|
|
|
Hi,
I have a Multiline Dialog Box would anyone have the sequence
of Win32 SDK API calls to calculate/set the number of characters in a
Line of a Multiline Dialog Box
BTW I am using Rich Edit 2.0 though I don't think this has any
bearing on my question
|
|
|
|
|
i guess it's done automatically
Don't try it, just do it!
|
|
|
|
|
what about CRichEditCtrl::GetTextLength() ?
how dumb of me... shoulda read the whole thing.
what about getting the whole text and looking for CR-LF and counting the characters between them ?
This signature was proudly tested on animals.
|
|
|
|
|
I am using Plains old C so EM_LINELENGTH
But if I cann't fit the Number of Characters I want on the Line
I would to some how want to make the font smaller ???
I guess I shoud re-prhase the question if I for Instance want 12
characters on one line of a MultiLine Dialog Box How Can I
calculate/set the right Font ??
|
|
|
|
|
I'm useing MFC and have a SDI app with Doc/View architecture. The main window has got two pane horizontally. Now I'm gonna change their height programmatically; but how?
Thank you masters!
|
|
|
|
|
|
See here[^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hello everyone,
Anything wrong with my code below? I got the compile error!
typedef unsigned char BYTE;
void foo(char* & p)
{
return;
}
int main()
{
BYTE * buffer;
foo ((char*)buffer);
return 0;
}
thanks in advance,
George
|
|
|
|
|
this isnt strange as foo required char*& and not char*.
Don't try it, just do it!
|
|
|
|
|
My confusion is reference type is the same as original type, for example when type Foo is needed, we could pass Foo or pass Foo&. So, I think then char* & is needed I could pass char*? What is wrong with my understanding?
|
|
|
|
|
BYTE is an unsigned char (8 bit)
char* is a pointer (32 bit)
When converting BYTE to char* then it needs to create a temporary variable. It is not possible to make return-by-reference with temporary variables.
Instead make the conversion from BYTE to char* by using a local variable, and then pass that local variable to the function.
|
|
|
|
|
I agree with your points, but confused. Since I am using BYTE* not BYTE.
Anyway, could you show me your code please? I think code clarifies everything.
regards,
George
|
|
|
|
|
Where is he converting a BYTE to char*? He's converting a BYTE* to char*. In other words, unsigned char* to char*. I think there's no problem with the pointer size.
this is enough:
foo ((char*&)buffer);
|
|
|
|
|
It's all to do with the semantics of casting - you can't pass a reference to something you've produced with a cast, even if the size and location of the thing is the same.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You must call it as below
char* pp = (char*)buffer;
foo(pp);
«_Superman_»
|
|
|
|
|
Your code fixes my issue, but why? I think both your code and my code are of the same effect.
regards,
George
|
|
|
|
|
When you typecast, you have to give the destination exactly as it should be.
So you could also typecast if as foo((char*& )buffer)
«_Superman_»
|
|
|
|
|
It's all to do with the semantics of casting - you can't pass a non-const reference to something you've produced with a cast, even if the size and location of the thing is the same.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hi,
I have an application which loads some images. when I changes the screen resolution position of images gets changed. How to manage image position while changing the screen resolution.
Thanks
|
|
|
|
|
what images? where are they displayed? how are they displayed?
Don't try it, just do it!
|
|
|
|
|
You can check new resolution with GetSystemMetrics.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi,
I created an C++ application an run Excel within that application by using the COM-Interface. For the development I use Visual Studio 2005. At the moment I'm be able to create an Excel application, create a worksheet and put Data on selected cells. Just see my code example.
Excel::_ApplicationPtr ExcelApp;
ExcelApp.CreateInstance(L"Excel.Application.9");
ExcelApp->put_Visible(10, true);
Excel::_WorksheetPtr pSheet;
pSheet = ExcelApp->ActiveSheet;
pSheet->Range["C1"]->Value = "Hallo World";
ExcelApp->Quit();
Now I'm trying to create a Excel ListBox throughout my C++ application. The problem is, that I'm not a experienced programmer. By searching the internet, I couldn't found any examples which would explain how to do that. In the excel9.tlh include, I found a ListBox decleration. The problem is that I don't know how to instantiate such a struct and conect it to a defined cell.
Thanks for your help.
|
|
|
|
|
After following the great tutorial on here: <a href="http://tldp.org/LDP/LG/issue74/tougher.html">http://tldp.org/LDP/LG/issue74/tougher.html</a>[<a href="http://tldp.org/LDP/LG/issue74/tougher.html" target="_blank" title="New Window">^</a>]
sources in folder here: <a href="http://www.sharedigest.com/SocketClientServer.zip">http://www.sharedigest.com/SocketClientServer.zip</a>[<a href="http://www.sharedigest.com/SocketClientServer.zip" target="_blank" title="New Window">^</a>]
I've managed to get the client and server talking to each other.
This is for an setup whereby data will be transmitted to my client via telnet from a remote server, and, according to them, I need to configure the client in such a way that it checks if the server dies and automatically attempts to reconnect after some (pre-specified) time period.
Currently, when I kill the server, I get ALOT of '' received by the client, continuously ... (output shown below, main routine shown below output)
I was wondering if there's a way to detect that the connection from the server's been lost, and consequently attempt to reconnect and keep listening for incoming messages?
Help much appreciated!
gvanto
socket newbie
<code>
Server:
pacific@mainbox /workspace/SocketClientServer/Debug$ ./SocketClientServer 0
starting server ...
Hello server from client.
Please enter string to send: hello back to client
Please enter string to send: another message
Please enter string to send: one more
Please enter string to send: //here i kill the server using ctrl+c
Client:
pacific@mainbox /workspace/SocketClientServer/Debug$ ./SocketClientServer 1
starting client ...
Sending hello server msg ...
Listening ...
We received this response from the server:
"hello back to client"
Listening ...
We received this response from the server:
"another message"
Listening ...
We received this response from the server:
"one more"
Listening ...
We received this response from the server: //AFter server killed, FLOOD of incoming BLANK messages received by client
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
""
Listening ...
We received this response from the server:
</code>
MAIN ROUTINE:
<code>
/*
* main.cpp
*
* Created on: 15/02/2009
* Author: pacific
*
* http://tldp.org/LDP/LG/issue74/tougher.html
*/
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include "ServerSocket.h"
#include "ClientSocket.h"
#include "SocketException.h"
#define DO_MAIN 1
using namespace std;
#ifdef DO_MAIN
int main(int argc, char *argv[]) {
if(argc > 1) {
/*****************************************************
* *********** SERVER *******************************/
if(atoi( argv[1] ) == 0) { //server mode
cout << "starting server ... " << endl;
try {
//Create the server socket
ServerSocket *server = new ServerSocket(30000); //set up socket and listen on local port
while(true) { //wait for incoming connections
/**
* Contains all of our socket information, used to exchange data with the client.
*/
ServerSocket new_sock;
server->accept(new_sock); //accept new incoming socket connection
try {
while(true) {
string data;
new_sock >> data; //read data from new_sock into 'data'
cout << data << endl;
//new_sock << data; //sends data in 'data' back throught the socket to the client (echo server)
string sendstr;
while(1) {
cout << "Please enter string to send: ";
getline (cin, sendstr);
new_sock << sendstr; //send it!
}
}
}
catch(SocketException&) {}
}
}
catch(SocketException &e) {
std::cout << "Exception was caught:" << e.description() << "\nExiting.\n";
}
}
/*****************************************************
* *********** CLIENT *******************************/
if(atoi(argv[1]) == 1 ) { //client mode
cout << "starting client ... " << endl;
try {
//Create the server socket
ClientSocket client("localhost", 30000); //set up socket and listen on local port
string reply;
try {
cout << "Sending hello server msg ... " << endl;
client << "Hello server from client. "; //send
}
catch(SocketException &) {}
while(true) { //keep listening
try {
cout << "Listening ... " << endl;
//client << "Test message. "; //send
client >> reply; //receive
}
catch(SocketException &) {}
std::cout << "We received this response from the server:\n\"" << reply << "\"\n";;
}
}
catch(SocketException &e) {
std::cout << "Exception was caught:" << e.description() << "\nExiting.\n";
}
}
}
else {
cout << "usage: ./SocketClientServer 0|1 (0 == server, 1 == client)" << endl;
}
return 0;
}
#endif
</code>
Find Your Dream IT-Job in Australia, Free!
http://www.WebCV.com.au
|
|
|
|