|
The above proved unsuccessful. What I did try was minimize the window and then restore it if the window was not already minimized. You can see the window minimize and then pop back up for display. Why does minimizing it work? This seems like poor coding to me but it serves as a workaround? How can I make it more efficient? Thanks!
if ( !pPrevWnd->IsIconic() )
{
pPrevWnd->ShowWindow(SW_MINIMIZE);
}
pPrevWnd->ShowWindow(SW_RESTORE);
pPrevWnd->SetForegroundWindow();
pPrevWnd->GetLastActivePopup()->SetForegroundWindow();
|
|
|
|
|
Hi fellows
I'm a doubt: I have this program to read each line of a file and write into it again with some new values, but the program doesn't read the lines and in the message box, it show the value "0". Who can helps me to solve this?
I want to read all lines of my file and write values in a determined position.
Below the code, thanks a lot for help:
void EscreveArquivo(char* cValues)
{
notas* tNotas = new notas;
char* cValue = new char[256];
FILE* pFile;
bool bEnd = false;
char* c = new char[256];
pFile = fopen("c:\\arquivo.txt", "a");
if(pFile != NULL)
{
while(!feof(pFile))
{
fread(cValue,4,1,pFile);
tNotas->iNota = atoi(cValue);
MessageBox(0, itoa(tNotas->iNota,cValue,10),"tela",0);
notas* aux = new notas;
aux->next = tNotas;
tNotas = aux;
break;
}
while(!bEnd)
{
//fread(tNotas, sizeof(tNotas), 1, pFile);
//tNotas->iNota += atoi(cValues);
switch(tNotas->iNota)
{
case 1:
i1Real += 1;
break;
}
itoa(i1Real,cValue, 10);
fseek(pFile, 2, 0);
fwrite(cValue, 1, 1, pFile);
if(tNotas->next == NULL)
{
bEnd = true;
}
tNotas = tNotas->next;
}
}
fclose(pFile);
delete tNotas;
delete[] cValue;
}
int main()
{
char* cBuffer = new char[256];
EscreveArquivo(itoa(10,cBuffer,10));
|
|
|
|
|
Alex Cutovoi wrote:
fread(cValue,4,1,pFile);
tNotas->iNota = atoi(cValue);
If you know the first item to read from the file is a number, why not treat it as such?
fread(&tNotas->iNota, sizeof(int), 1, pFile); Alex Cutovoi wrote:
tNotas->iNota = atoi(cValue);
atoi() will not work unless cValue is nul terminated.
What exactly are you trying to do? All of the calls to atoi() and itoa() appear to be making things unnecessarily hard.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
when you compile that code, you should see a warning that looks a lot like this: "warning C4129: 'm' : unrecognized character escape sequence".
\ is the C/C++ escape character, so if you want to put a single '\' inside a literal string, you have to use '\\' .
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
because when you hard coded sValue, the compiler sees '\m' as an escape character...
make this instead :
char sValue[] = "So\\meText";
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 11:24 Wednesday 5th October, 2005
sorry Chris, i have a very very very slow connection today, so excuse my redundant answer... (or CP servers are having trouble ?)
|
|
|
|
|
I need to write a program to send data to com port with 8bit characters.
(0x00 - 0xFF)
But I can only use CString as 7 bits ANSI.
Please tell me how to use CString as 8 bits!
Thank you very much!
|
|
|
|
|
|
Chris Losinger wrote:
you can't.
you uderstood the question ????
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hello,
CString uses 8 bits! A byte is 8 bits and CString uses no less... If you want to specify values other than the visible characters, you should call GetBufferSetLength(new length) . This will retrieve a pointer to the internal character buffer. Manipulate it as required (using code>unsigned char's and a lot of casting. Then call ReleaseBuffer() and make sure that there are no null terminators in the buffer, but only one on the end.
This is a dirty hack that you should not use, but use a BYTE buffer or
unsigned char<code> buffer instead!<br />
<br />
Hope this helps :) <br />
<br />
Behind every great black man...<br />
... is the police. - Conspiracy brother<br />
<br />
<br />
<a href="http://www.codeproject.com/script/profile/whos_who.asp?id=418947&id=418947&df=100&forumid=27215&exp=6&select=1050632">Blog</a>[<a href="http://www.codeproject.com/script/profile/whos_who.asp?id=418947&id=418947&df=100&forumid=27215&exp=6&select=1050632" target="_BLANK">^</a>]
|
|
|
|
|
Hello,
I need to use CString because I use the VT_BSTR of VARIANT for using com port.
So could you tell me how to solve this problem or other method to do the com port program?
Please help!
Many thanks,
Alex
|
|
|
|
|
Hi Alex,
Try the following:
VARIANT var;<br />
CString str = "My serial data";<br />
var.vt = VT_BSTR;<br />
var.bstrVal = str.AllocSysString();
There's a lot written about serial programming here: http://www.codeproject.com/system/#Hardware+programming[^]
Hope this helps
--
Roger
|
|
|
|
|
Hi
Now I can send the data to com port in binary form,
CByteArray btArray;
int total;
total=GetDlgItemInt(IDC_EDIT1,NULL,TRUE);
btArray.Add(total);
COleVariant var(btArray);
m_comm.SetOutput(var);
VariantClear(&var);
but I can't receive in correct way.
Please help!
|
|
|
|
|
Alex Hon wrote:
I can't receive in correct way
What does this mean? Who is the receiver?
If you're having trouble with VARIANTs and MsCommCtrl, describe them.
What does the vt field in the VARAINT union say about how the data should be interpreted?
--
Roger
|
|
|
|
|
Hi Roger,
For example, I send the data is 0x8f (binary is 10001111).
I check the data in the line is 0x8f.
But I will get a 0x01 in VARIANT in receiving PC.
If the data is between 0x00 to 0x7f, it will be correct.
Please help!
|
|
|
|
|
You need to change the mode of the MsCommCtrl from text to binary.
Also be careful when calling GetInput how the VARIANT union should be interpreted. I suspect that the binary data will be a SafeArray.
I always write my own serial port handler since I consider the MsCommCtrl to be slow, to limiting and not very well documented to say the least.
E.g. you can have COM ports from COM1 to COM255 in the OS, but MsCommCtrl can only handle COM1 to COM16. Connect som devices such as a mobile phone, BlueTooth dongle and you easily get more than 15 ports.
Hope this helps
--
Roger
|
|
|
|
|
Thank you very much!
By using SafeArray.. , the receiving part is working now.
Thank you very much again!
|
|
|
|
|
Hallo Community,
does anyone have experience with Exception 0xE06D7363, when run in debug modus, the output window shows this message:
First-chance exception in LinkChek.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
and i dont know what kind of error is this???
thanks for help
break;
|
|
|
|
|
Hello,
You probably screwed something up in an API call. Some of the parameters might have incorrect values. It is impossible for me to say what is wrong from this point of view. Try to step into the debugger and see when the exception occurs, post more info on this later.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello Bob,
thank you for answer, i try to debug step by step, maybe i can find the point where is error created, and i post a pease of code here!
regards
break;
|
|
|
|
|
Importing a dll which was has an enum with a German Umlaut (like 'ä') makes no problems using Visual Studio .Net 2003, but causes Visual C++ 6 to an error (error C2018) which means 'unknown character'. So the .tlh file is generated within every build I have no chance to modify it. Even setting this file to read-only causes the compiler to make problems. Does anyone know a solution for Visual C++ 6 to make the dll work e.g. a setting in the project ( Win32 MFC Project Dialog based) ?
|
|
|
|
|
Hi!!
I'm trying to figure out a way of removing symbols from a standard library. I've only been able to extract whole object modules from the library at the commandline like so:
lib name.lib /extract:module.obj /out:result.obj
or remove entire object modules like so:
lib name.lib /remove:module.obj /out:result.lib
I'm trying to remove a DllMain implementation from the library because I need to create my own in the dll that uses the library. I get linker errors saying that i've got a multiply defined symbol i.e. _DllMain@12 (similar to what you'd expect). I can't remove the object module that contains it because it also contains symbols that i need.
Does anyone have any idea how to get around this? I may be going about it all wrong!?
Thanks!!
|
|
|
|
|
Why not encapsulating the DLL instead of messing around? You'll most probably receive an updated version of the file with the next Service Pack, and you'll need to do the work again. I'd rather write my own DLL that simply calls the standard one, are there any obstacles here?
Regards,
BB
http://spin.bartoszbien.com
|
|
|
|
|
there are a few 3rd party libraries (.lib's) that either perform the linking / mapping to symbols in dlls, or actually contain code. the library that actually contains code (that i need) also contains the DllMain, but as i mention, i really need to implement my own DllMain. So in other words my own dll encapsulates functionality provided by the other dlls AND libraries, but i can't dynamically link to all symbols, because they're actually provided within a .lib.
is there any way of extracting/removing symbols from .lib's/.obj's that i need/don't want?
|
|
|
|
|