|
Why not just write a routine that adds a char to the end of a string passed to it, then you'd just need to do something like this:
string s;
for (int i = 0; i< iNumOfChars; i++)
AddChar(s);
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Ooops - just thought that through. I suspect you may need to do something recursive that adds the strings to an array or prints them as it goes.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
I would like to use the IPAddress Control as provided by Microsoft in a VB Application. In VB, unlike VC, you can't just add the control to a form, it is just not in the toolbox.
I tried to create a new (subclassed) ActiveX control but I could not get things to work.
Does anyone know how to get this to work? Or can someone explain to me, why it can't be done (if so)?
Greetings,
Patrick
|
|
|
|
|
i need to get info about the controls in a window created by some other application from my application.this works fine for integer variables li but the problem comes when accessing pointer type variables.
for e.g. using SendMessage for getting the RECT values of a track bar control does not work.any clues?
|
|
|
|
|
i need to get info about the controls in a window created by some other application from my application.this works fine for integer variables li but the problem comes when accessing pointer type variables.
for e.g. using SendMessage for getting the RECT values of a track bar control does not work.any clues?
|
|
|
|
|
i need to get info about the controls in a window created by some other application from my application.this works fine for integer variables li but the problem comes when accessing pointer type variables.
for e.g. using SendMessage for getting the RECT values of a track bar control does not work.any clues?
|
|
|
|
|
Ok, so I know it is not that difficult but I can't find the correct arguement to make
a checkbox control go invisible (essentially, just need to make some of the controls on
my dialog disappear when certain conditions are met).
I retrieved the pointer to the cbutton object cbutton* mycontrol = (cbutton*)GetDlgItem(ID_Control)
thought I could use mycontrol->setbuttonstyle( ) .....but don't know which arguements.
thanks....please email straight to lrector@netzero.net
|
|
|
|
|
You're right, it's not difficult.
mycontrol->ShowWindow( SW_HIDE );
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
--Buffy
|
|
|
|
|
|
Does anyone know if it's possible to roll my own CA and PKI for NT Workstation Security. For various reasons, I want to be able to work with signed code and SSL connections in a peer-to-peer NT Workgroup (no servers, just four workstations). I can't set up the personal web server (IIS 4.0 personal web server from the NT Option Pack) to handle https and SSL without a Verisign certificate so I would like to create and install my own CA certificate as a root trusted authority in the Trusted Computing Base.
Here's the problem: A University network allows potentially hostile users access to the local network. I want to set up four workstations as a VPN or something similar, but don't have the budget to sacrifice one computer as a server and create a domain. Thus, I would like to secure communications among the workgroup as much as possible. At the minimal level, I would like to get the computers talking to one another using https rather than http, but can't do this without spending a large fraction of my computing budget on Verisign keys.
I haven't seen anything about this anywhere in MSDN or in the magazines. Does anyone know if it's possible? If it is possible, where should I look to learn more?
He was allying himself to science, for what was science but the absence of prejudice backed by the presence of money? --- Henry James, The Golden Bowl
|
|
|
|
|
How do I get the decimal eqivalennt of a 2's complement hex number in VC++ 6.0? In other words, how can I convert FD to a -2 given that FD is a 2's compliment hex number?
Regards,
Mike Zolna
|
|
|
|
|
I'm not sure exactly what you need. A number is a number, no matter how it's stored or what base (decimal/hex) you represent it in. But if you want to go from the number 0xFD to the string "-3" (0xFD is -3, not -2) then just sprintf() it:
char szNum[16];
signed char num = (signed char) 0xFD;
sprintf( szNum, "%d", (int) num ); // cast sign-extends 0xFD to 0xFFFFFFFD
You need to use the "%d" format since that prints the value of a number. The (int) cast puts the correct number of bytes (int-sized, instead of char-sized) on the stack.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
--Buffy
|
|
|
|
|
I'm assuming you have FD as text, and need to convert it. I don't think there's a built in way to do this. Some searching reveals a couple of 'hex string to value' conversion routines, one in SNA. Found HEX2INT.PRG in the docs for FoxPro 2.5 for DOS... hmmm...
Oh well, never pass up a chance to fill up a message with a nice pale orange block...
#include <iostream>
using namespace std;
long Hex2Int(char * pszHex) {
static unsigned char byteLookup[22][2] =
{ '0', 0, '1', 1, '2', 2, '3', 3, '4', 4, '5', 5, '6', 6, '7', 7,
'8', 8, '9', 9, 'A', 10,'B', 11,'C', 12,'D', 13,'E', 14,'F', 15,
'a', 10,'b', 11,'c', 12,'d', 13,'e', 14,'f', 15
};
register long total = 0;
int nPosition = 0;
if(*pszHex) {
register int len = strlen(pszHex) - 1;
while (len >= 0) {
bool bFound = false;
int i;
for (i = 0; i < sizeof(byteLookup)/2; ++i) {
if(byteLookup[i][0] == *(pszHex+len)) {
++bFound;
break;
}
}
if(!bFound) throw "Invalid hex number\n";
if(nPosition == 0) {
total = byteLookup[i][1];
}
else {
total += byteLookup[i][1] << (4 * nPosition);
}
--len;
++nPosition;
if (nPosition > 8) throw "Too many hex digits\n";
}
}
else {
throw "Empty string\n";
}
return total;
}
int main(int argc, char* argv[])
{
char s[255];
long result = -1;
while (result) {
cout << endl << "Enter a hex number please, or 0 to exit: ";
cin >> s;
try {
result = Hex2Int(s);
cout << endl << "Hex2Int returned " << dec << result << " [" << hex << result << "]" << endl;
}
catch (char * e) {
cout << e;
}
}
return 0;
}
Note that there's room for optimization here, and there's the issue (see comments) of sign extension. This Hex2Int returns 253 for FD, -3 for FFFFFFFD. But I think you need something like this to do the translation.
|
|
|
|
|
Hey Everybody,
I'm looking for a GZIP file compression library/api or something. I'm writing a vrml file export utility, and since the generated *.wrl files are inherently large, being text files, I'd like to export them in *.wrz format which requires gzip compression.
Anyone have any suggestions on gzipping a file programmatically?
Thanks,
Josh
josh@schroff.com
|
|
|
|
|
Get zlib. This is the canonical library for zipping and unzipping content. You can also look right here on CodeProject at SawZip, Zip and Unzip the MFC Way, and Self-Extracting File Framework.
He was allying himself to science, for what was science but the absence of prejudice backed by the presence of money? --- Henry James, The Golden Bowl
|
|
|
|
|
Ok, with a bit research in MSDN and in the header files, I menaged to collect the following information:
The following code should do easy and fast transparent Blt'ing... BUT as my driver doesn't support (pDC->GetDeviceCaps(CAPS1) & C1_TRANSPARENT) or as there is something wrong with this code, I cannot be sure if it works...
#ifndef C1_TRANSPARENT
#define C1_TRANSPARENT 0x0001
#endif
#ifndef CAPS1
#define CAPS1 94
#endif
#ifndef NEWTRANSPARENT
#define NEWTRANSPARENT 3
#endif
int nSave = pDC->SaveDC();
if(pDC->GetDeviceCaps(CAPS1) & C1_TRANSPARENT)
{
pDC->SetBkMode(NEWTRANSPARENT);
pDC->SetBkColor(crTrans);
pDC->BitBlt(rcDest.left, rcDest.top, rcDest.Width(),
rcDest.Height(), &imageDC, 0, 0, SRCCOPY);
} else
{
}
pDC->RestoreDC(nSave);
This feature is very well undocumented in MSDN, and C1_TRANSPARENT and CAPS1 isn't even defined in the standard headers!!
Any suggestions??
Enjoy, Marc
|
|
|
|
|
Do not use it.
It may be defined during Windows 3.1 time, but I donot know any driver which supports it.
|
|
|
|
|
I have raw serial data being displayed to the screen in ASCII format. I need this data in HEX format, but am not familiar enough with C++ to accomplish this. Here is the code that outputs to window and file in ASCII:
{
for (i=0; i
|
|
|
|
|
Here's some thoughts - you might be able to tinker with one of these. Basically, an intermediate step is involved to take the char and format it as hex.
#include "windows.h"
#include <iostream.h>
#include <strstrea.h>
#include <stdio.h>
void OutHex(char c) {
char buf[8];
sprintf(buf,"%X ", c);
cout << buf;
}
int main(int argc, char* argv[])
{
char test[] = "Here's some char data";
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
strstream ss;
DWORD dwBytesWritten;
char *p;
cout << "Method 1:" << endl;
for ( p = test; *p; ++p) {
cout << hex << (int)*p << " ";
}
cout << endl << "Method 2:" << endl;
for ( p = test; *p; ++p) {
ss << hex << (int)*p << " ";
}
WriteConsole(hStdOut, ss.str(), ss.pcount(), &dwBytesWritten, NULL);
cout << endl << "Method 3:" << endl;
for ( p = test; *p; ++p ) {
OutHex(*p);
}
int x;
cin >> x;
return 0;
}
|
|
|
|
|
I need my application to get notified when teh file opened in it is modifed outside its editor and give user the option to reload it from disk
like Visual C editor do
Regards
Ali
|
|
|
|
|
I am trying to write a control application for the Windows Media Encoder using the Microsoft supplied Media Format SDK and Media Encoder SDK. I must use the WAVEFORMATEX structure in order to properly set the audio streaming configuration. In the two SDKs as well as the DirectX 8.0 SDK and MSDN it states formulas to calculate the nBlockAlign and nAvgBytesPerSec. Does anyone know if these formulas are correct? I looked at data used by already existent stream configurations and the values given do not match the values gotten when using these formulas. Any help?
Roger Printy
Software Engineer
TeraNex
Orlando, FL
|
|
|
|
|
Does anybody here use the FormatMessage function? I copied the code described in MSDN but the function returns an invalid buffer when I try to show messages over 3006.
...
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(), // works great for messages within 0-3006.
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Display the string.
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
...
Could anybody help me?
|
|
|
|
|
Hi,
I use this custom function and it work :
/**=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=\
| ShowErrorMessage : Affiche le message d'erreur correpondant au numéro d'erreur
| que retourne la fonction GestLastError() |
| --------------------------------------------------------------------------------------
|Arguments : dwMessageId -> Numéro d'erreur retourné par GetLastError()|
| Titre -> Titre de la boîte de message (facultatif)
|
|Si le numéro d'erreur est 0 ( i.e ERROR_SUCCESS ), la fonction n'affiche pas le message
|-----------------------------------------------------------------------------------------|
|EXEMPLES D'UTILISATION :
|------------------------
| 1) ShowErrorMessage(GetLastError());
|
| 2) DWORD NumErreur;
| NumErreur=GetLastError();
| ShowErrorMessage(NumErreur);
=**=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=**/
void ShowErrorMessage(DWORD dwMessageId, char* Titre)
{
if (dwMessageId==ERROR_SUCCESS) return;
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwMessageId,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Affiche la chaîne.
MessageBox( NULL, (LPCTSTR)lpMsgBuf,Titre, MB_OK | MB_ICONINFORMATION );
// Libère le buffer.
LocalFree( lpMsgBuf );
}
|
|
|
|
|
Hi!
Thanks for the help!
I made more tests with Windows NT and it works (shows messages above 3006). But, it still does not work on Win95/98.
Anyway, thank you.
|
|
|
|
|
Hi,
I want to get programmaticaly the default domain name. instead to use API function, i retrive this information from windows registry
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"CachePrimaryDomain"="SRV_DEV"
If this method is'nt correct, anybody can help me how to get this name using API Function?
I work with Visual C++ 6.0 Windows NT4
Thanks in advance
|
|
|
|
|