|
1 bit, one 1 byte ???
you have many functions to read files, but only 1 byte at least.
what you could do so is reading the byte, and exctracting its bit that's interresting you...
for example, i want the bit b4 of the first byte of the file (i consider b0 is the LSB, and b7 is the MSB) :
<font color=#0000FF>int </font>file = fopen(<font color=#808080>"file1.txt"</font>, <font color=#808080>"r"</font>);
<font color=#0000FF>char </font>cByte = 0;
fscanf(file, <font color=#808080>"%c"</font>, &cByte);
<font color=#0000FF>bool </font>bBit_b4 = (cByte & 0x10) >> 4;
<font color=#0000FF>if </font>(bBit_b4) {
<font color=#008000>
}
else {
<font color=#008000>
</font>}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
thanx!!
i am doing in a similar fashion..
i just thought if there is any direct function
|
|
|
|
|
POSITION pos = GetFirstViewPosition();
CString temp;
while (pos != NULL)
{
CRichEditView* pView = (CRichEditView*) GetNextView(pos);
int i, nLineLength, nLineCount = pView->GetRichEditCtrl().GetLineCount();
CString strText, strLine;
// Dump every line of text of the rich edit control.
for (i=0;i < nLineCount;i++)
{
nLineLength = pView->GetRichEditCtrl().LineLength(i);
pView->GetRichEditCtrl().GetLine(i, strText.GetBuffer(nLineLength));
AfxMessageBox(strText);
strText.ReleaseBuffer(nLineLength);
}
}
I think there`s a problem with the CString allocation memory.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Yulianto AKA goodmast3r wrote:
AfxMessageBox(strText);
strText.ReleaseBuffer(nLineLength);
These two lines should be switched. Straight from MSDN:
If you use the pointer returned by GetBuffer() to change the string contents, you must call ReleaseBuffer() before using any other CString member functions.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Besides the problem mentioned with using CString::GetBuffer(...) and CString::ReleaseBuffer(...) , I believe you should be using nLineLength + 1 in the call CString::GetBuffer(...) to store the line extracted from the Rich Edit control to account for the terminating NUL character.
Peace!
-=- James
Tip for inexperienced drivers: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
In OnInitDialog() of a class which inherits from CDialog,
SendMessage(WM_CLOSE) will close the dialog, but when using
::SendMessage((HWND)(CWnd*)this,WM_CLOSE,0,0);
it couldn`t close the dialog, where did I do wrong?
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Why Don't you try
::SendMessage(this->GetSafeHwnd(),WM_CLOSE,0,0);
or
::SendMessage(this->m_hWnd,WM_CLOSE,0,0);
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Why Don't you try
::SendMessage(this->GetSafeHwnd(),WM_CLOSE,0,0);
or
::SendMessage(this->m_hWnd,WM_CLOSE,0,0);
OFFTOPIC:Yulianto AKA goodmast3r?,if you don't mind could you tell me meaning of your name Yulianto.
Thanks
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
ThatsAlok wrote:
OFFTOPIC:Yulianto AKA goodmast3r?,if you don't mind could you tell me meaning of your name Yulianto.
Ehmm, No particular meaning. I was born on July. I think it`s a bad name, but anyway it was given by my parent. And what`s the meaning of
ThatsAlok
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Yulianto AKA goodmast3r wrote:
I was born on July
ME too , July THE 11
Yulianto AKA goodmast3r wrote:
what`s the meaning of
ThatsAlok
Alok has two meaning Light or Man with Beautiful hair.
and thatsalok mean i think it's simple thatsalok
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Your mistake is that you convert a pointer (this) to a window into a handle.
You have to do like this:
<br />
::SendMessage(m_hWnd,WM_CLOSE,0,0);<br />
SkyWalker
|
|
|
|
|
I have nearly finished my little beginners project and need help in formatting the output my code is below. My question is after the code
/////////////////////////////////////////////////////////////////////////////
// CReverseView message handlers
void CReverseView::OnReverse()
{
// TODO: Add your command handler code here
CEdit &edit = GetEditCtrl();
CString strText;
CString msg = "\r\nThe answer is ";
CString data; // storage for the read in data'
CString line; // to concactenate msg & data
BYTE a;
edit.GetWindowText(strText);
while (!strText.IsEmpty())
{
sscanf(strText,"%c",&a); //read the char
data = (BYTE)a; // put it in data
strText=(const char*)strText1;+1
// move the pointer
line = msg+=data;
// add CR/LF "The message is" to the beginning
}
strText = line;
edit.SetWindowText(strText);
//This prints The answer is qwerty
GetDocument()->SetModifiedFlag(TRUE) ;
}
The above code prints
The answer is qwerty
I want it to print out like this:-
The answer is q
The answer is w
The answer is e
The answer is r
The answer is t
The answer is y
It seems my string objects over write each other. How do I fix this or re set the "object counter" back to zero so that it overwrites the existing data? I have tried many ways but can't work it out
Thank you
|
|
|
|
|
hugPW wrote:
strText=(const char*)strText1;+1
The above statement should not compile.
How about something small like:
edit.GetWindowText(strText);
for (int x = 0; x < strText.GetLength(); x++)
line += "The answer is " + strText[x] + "\r\n";
strText = line;
edit.SetWindowText(strText);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you!!,
yes there was a typo in the code (extra1)
I found by trial & error an even easier way
strText=(const char*)00; // reset the string pointer
It works for my project and the output is how I want it.
Now all I want to do is change the font as the text is uneven, I believe it is set true type, with different widths for different characters.
I want it to display constant width characters. (like notepad)
Thank you again for your kind support
|
|
|
|
|
hugPW wrote:
strText=(const char*)00; // reset the string pointer
Wrong. strText is not a pointer, it is a CString object. Use the Empty() method instead.
hugPW wrote:
Now all I want to do is change the font as the text is uneven, I believe it is set true type, with different widths for different characters.
This is called proportional spacing as opposed to mono or fixed spacing.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks again !
How do I change from proportional to fixed spacing?
The program is basically a MFC single document interface created with the wizard
Regards
Peter
|
|
|
|
|
While I've not actually tried it, I think you can create a CFont member variable in the CView -derived class. In the view's OnCreate() method, create the desired font. Then call SetFont() with a pointer to the newly created font.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
How do I change from proportional to fixed spacing?
Basically, the program is a MFC Single Document Interface
Regards
Peter
|
|
|
|
|
Hi,
I'm using CrateFile(),WriteFile(),ReadFile() functions when my application works with the serial ports(COM1,COM2,...).
Now I need to do this with the USB port.
How can I do this?
Any links,samples,tutorials will be helpful.
Best regards,
Eli
|
|
|
|
|
Are you using a RS-232 to USB adapter ? (a cable that enables you to use a serial device in the USB port). If yes, this is exactly the same because it is considered as a virtual COM port...
If no, this is much more complicated because you need a driver (that is normally shipped with the USB device), and there must be normally some doc supplied with it. You open the communication using the CreateFile function but you 'communicate' with the driver using special commands (that are specific to your USB device). These commands are sent using the DeviceIoControl function
Hope this helps
|
|
|
|
|
Hi,
First,thanks for your prompt reply.
I have RS232 to BlueTooth adapter that works fine through COM1 port.
Now i need to do the same,but with USB dongle(USB to BlueTooth).
When the communication is through the serial port,i'm using
CreateFile("COM1:",.......);
Do you know what should i send instead "COM1:" to open the USB port?
My problem is not communicate with the driver - my problem is to open the USB port.
Best regards,
Eli
|
|
|
|
|
Ok, so here forget about the second part of my message, that was just in case of a specific USB device (no virtual COM port).
For your case, first check which port number is created by your adapted (plug your cable and check this in the device manager: you will have the complete list of ports that are on the computer with their numbers). The second thing is that you don't need to provide the ":" this is just "COM1".
One last thing is that ports greater than 9 must be opened like this: "\\.\COM10" (don't forget to supply a double '\' if coded in a string...)
|
|
|
|
|
well i dunno if u can use the writeFile()...etc directly as u do for the serial port but u can send the data to the Usb either by using the built in drivers in windows for usb or u will have to make one urself.....
I have sent data to the usb windows driver (midi data).....but if u r building ur own driver.....thatz a lot of work
herez one link
try out this link......it tell u all u need to know abt how to send data thru usb using windows drivers and also ur own made usb driver.....
http://www.lvr.com/usb.htm[^]
gud info....
hope that helpz.....
cheerz.....
|
|
|
|
|
..morning...
How do I convert a char to an int int VC++?
doneirik
|
|
|
|
|