|
dSolariuM wrote: I want to use windows media player activex in my mfc app.
Just drag and drop the Media player on your dialog.... these classes will get added automatically
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi guys,
i have a dialog with a listbox. the styles for the listbox are 'Border, Multicolumn, Vertrical scroll'.
But the listbox never shows the vertical scrollbar.
anyone can help?
P.
|
|
|
|
|
The multicolumn style makes it add strings in new columns, not in the same column. so it does not need a vertical scrollbar. Therefore, it seems that you need to include the 'Horizontal scrollbar' style, or exclude the 'Multi column' style.
this is this.
|
|
|
|
|
I use the MDI Frame-View Framework,when popup a new window,I want to set the size of window with the size of associated document, I should use SetWindowPos function, but I do not know when to use it and how to set the parameters ?
Thanks!
|
|
|
|
|
I have trouble in writing a CRC CCITT program.
My program is :
#define CRC_CCITT 0x011021
#define INIT_CRC16 0x01ffff
int nn=0, n=0, nbytes=CRCArray.GetSize();
crc = INIT_CRC16;
while(nbytes-- > 0)
{
nn=CRCArray.GetAt(n);
for (i=0x80; i >=0x01; i>>=1)
{
crc <<= 1;
if (nn&i)
crc = crc^0x000001;
else
crc = crc&0xFFFFFE;
if (crc & 0x010000)
crc ^= CRC_CCITT;
}
n++;
}
I get a correct answer as this website
http://zorc.breitbandkatze.de/crc.html
But I got a wrong answer with my tester.
I know that the crc program of my tester is using "fast crc"(fcstab).
// Initialize the Init Flag
*theCrc = theInitFlag;
int length = theBuffer.length();
// Create the crc using fcstab
for (int i = 0; i < length; i++)
{
(*theCrc) = (unsigned short)(((*theCrc) >> 8) ^ fcstab[((*theCrc) ^ theBuffer[i]) & 0xff]);
}
Is there any one try this before?
Please help!
|
|
|
|
|
I had a similar problem once (written by someone else, of course ).
The couse of the problem was the usage of signed datatypes (int, long).
When I made sure that all variables and calculations were using on unsigned datatypes, then i got the correct result at all times.
Previously, "my" results was right at some calculations and wrong at other times.
Maybe that's your problem too?
|
|
|
|
|
I think they are unsigned databytes.
I get single "A" with CRC 0x9479, "123456789" with CRC 0xE5CC.
They are correct to a lot of website in "good crc".
But I would like to know is it the same result with "fast crc"?
(using fcs table lookup)
I tried this input
0513C1302602010004065075626C6963A0190201000201000201003003300C06082B060102010105000500
CRC=0872
Could you tell me what you get in your crc checking?
Please help!
|
|
|
|
|
I had to rewrite your code sligtly, since my "dummy-project" isn't MFC.
This is what I get (F1CE hex). I don't know if it's right or wrong.
void calc()
{
#define CRC_CCITT 0x011021
#define INIT_CRC16 0x01ffff
unsigned char * CRCArray = (unsigned char *) "0513C1302602010004065075626C6963A0190201000201000201003003300C06082B060102010105000500";
int nn=0, n=0, nbytes=strlen((char *) CRCArray);
unsigned int crc = INIT_CRC16;
int i;
while(nbytes-- > 0) {
// nn=CRCArray.GetAt(n);
nn=*(CRCArray + n);
for (i=0x80; i >=0x01; i>>=1) {
crc <<= 1;
if (nn&i)
crc = crc^0x000001;
else
crc = crc&0xFFFFFE;
if (crc & 0x010000)
crc ^= CRC_CCITT;
}
n++;
}
// crc becomes F1CE
}
|
|
|
|
|
Sorry!
I mean the correct CRC of this "0513C1302602010004065075626C6963A0190201000201000201003003300C06082B060102010105000500" is 0872. I get the other answers.
Please help!
|
|
|
|
|
Alex Hon wrote: I mean the correct CRC of this "0513C1302602010004065075626C6963A0190201000201000201003003300C06082B060102010105000500" is 0872.
Actually, according to the website you gave the correct CRC is 0x1872 when using the nondirect option.
|
|
|
|
|
The 0513C1302602010004065075626C6963A0190201000201000201003003300C06082B060102010105000500 are hex.
The website which I gave is only supported character.
|
|
|
|
|
I have created a View in CView and displayed it in a
child window , now i want to print the data in the view .
So i used the OnFilePrint(); function but i get very
small size of fonts on the print.
I get the satandard Print Dialog & also succesfull printout but
1) How to set the page size for printing .
2) How to set the print dialog parameters.
3) How to add a Page Break .
Thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi --
I find getline() function to be extremely slow when reading data from a text file. I tried replacing getline with a homemade function called getChunk (shown below) but it's just as slow.
getChunk(std::istream &in, std::string &s, const char terminator)
{
s.erase(s.begin(),s.end()) ;
s.reserve(10) ;
std::string::value_type ch ;
while (in.get(ch) && ch != terminator)
s.insert(s.end(),ch) ;
}
For context, here's the core of my program:
rawData.reserve(numberRecords) ;
int counter=0 ;
do
{
counter=counter+1 ;
std::vector <std::string> record ;
record.reserve(numberVars) ;
for(int i=0; i<numbervars-1; i++)
="" {
="" getchunk(*data,value,',')="" ;
="" std::getline(*data,value,',')="" record.push_back(value)="" }
="" getchunk(*data,value,'\n')="" std::getline(*data,value)="" rawdata.push_back(record)="" ;=""
="" std::vector="" <="" std::string="">::iterator j ;
j=record.begin() ;
record.erase(j, j+numberVars) ; } while (counter < numberRecords) ;
numberRecords=rawData.size() ;
Can anyone help me out here?
Thanks,
Kim Larsen
|
|
|
|
|
webHamlet wrote: while (in.get(ch) && ch != terminator)
it seems u r reading the data one byte at a time, which would slow down the process anyways.
if i were u, i wud've read a large chunk(5-10kb maybe) of data from the file into memory buffer and then read and interpret text data from it.
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
Thanks..
How do I do this? Could I use the read() function, or is there a way to make getline grab larger chunks?
Kim
|
|
|
|
|
Are you sure that it's the file I/O that's the problem?
Maybe you (for testing purposes) should isolate the file reading from the storing of the data. And the compare file read times?
|
|
|
|
|
Hi --
Thanks..
I'm 100% sure it's getline.
Kim
|
|
|
|
|
Hi.
You could try to read the file using the old f-functions, like fopen, fgets, fclose.
Read the data to a char[], and then assign it to the string.
It might help.
Principle:
char buffer[300];
FILE * file = fopen("filename", "rt");
if(file != NULL) {
while(fgets(buffer, 300, file) != NULL) {
string = buffer;
..... Save it here
}
fclose(file);
}
|
|
|
|
|
Hi,
I am writing a DLL in VC++, which needs to send and receive messsages using sockets.
Everything goes until I create the Socket using the Object of the CAsyncSocket derived class.
The error message it gives me is this :
error2248 : Cannot access public member 'Create' of CAsync Socket
I've checked the MSDN Error Code. But all I get is that it needs to keep the same state.
Please reply as soon as possible.
|
|
|
|
|
Show your code section,please
You are the best!Me too!
|
|
|
|
|
That problem has been solved. I was not deriving CAsyncSocket class as public(goofed up).
But still I have a problem. I want to use the socket in an Extension Dll, that is used by the SNMP Service. Yes, I am developing an SNMP Agent. I want to use sockets to send/recieve data, for which I need the services of a socket.
#include "Connector.h" // The file that comprises of the CAsyncSocket derived class
Connector Cn;
// Entry Point for the DLL
BOOL APIENTRY DllMain(...)
..
{
WSADATA wsaData;
long Events = FD_READ | FD_WRITE | FD_CONNECT | FD_CLOSE | FD_ACCEPT;
WSAStartup(MAKEWORD(1,1),&wsaData);
AfxSocketInit();
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
/* The problem lies here. If I don't use this line tha Agent will send traps correctly. But when I create this socket nothing happens. The Agent does not send traps *1
Cn.Create(128,SOCK_DGRAM,Events,"127.0.0.1");
break;
I dont seem to know what is the problem.
Please Reply as soon as possible as I am working on a project.
Thanks
|
|
|
|
|
You can read follow samples,maybe you can find a solution from them:
http://www.codeproject.com/internet/SNMP_Agent_DLL__Part1_.asp
http://www.codeproject.com/internet/SNMP_Agent_DLL__Part2_.asp
http://www.codeproject.com/internet/mdftpclient1.asp
http://www.codeproject.com/internet/LymingtonPGO.asp
1.You can create class object in your services.
2.In your services,you initialize CSocket,maybe it is useful.
You are the best!Me too!
|
|
|
|
|
Hello!
I cannot solve two problems with my Rich Edit control (that I use in a dialog form):
1. How can I make it accept Tab keys. When I press the Tab key now my Rich Edit just looses focus instead of printing '\t'.
2. When I select some text with images or other OLE objects in some application, copy it and than paste in my Rich Edit, all the copied object (text, images, ole) appears in it. But I need to paste only text. I know of CRichEditCtrl::PasteSpecial(CF_TEXT) but don't know where to use it.
Thank you in advance.
|
|
|
|
|
Reunion wrote: 1. How can I make it accept Tab keys. When I press the Tab key now my Rich Edit just looses focus instead of printing '\t'.
Just a guess, but what does ctrl+tab do?
Reunion wrote: I know of CRichEditCtrl::PasteSpecial(CF_TEXT) but don't know where to use it.
Use it at the point in which you wish to add text to the clipboard.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Ctrl+tab does what I need, but how can I do the same with just tab?
|
|
|
|