|
My GUI looks not good, what can i do for looking some flashy or classical looks?
|
|
|
|
|
Use picture in background of your wins.
|
|
|
|
|
Hi
In my program, i use read/write mode for file operation. But it not working properly. Code as follows
fstream f("temp.txt",ios::app | ios::in )
kindly help
thanks
KK
|
|
|
|
|
kk.in wrote: But it not working properly
Fine, and we are supposed to guess what is going wrong ? And what you are expecting ?
kk.in wrote: ios::app | ios::in
You know that you will only be able to read the file (and I don't know why you used ios::app here, this is only usefull when writing to the file).
|
|
|
|
|
Hi
The real problem is
I have a text file with some data, I want to edit data from a particular position,it without using temperory file. I try to edit the data and it will added to end of the file ?
thanx
KK
|
|
|
|
|
You need to use the ios::out flag if you want to write something to the file (otherwise it is read-only)
kk.in wrote: I have a text file with some data, I want to edit data from a particular position,it without using temperory file.
You can't do that, you cannot insert data at a certain position (only write on it but you won't be able to insert extra characters).
|
|
|
|
|
kk.in wrote: I have a text file with some data, I want to edit data from a particular position,it without using temperory file.
While you can certainly change text (e.g., replace dog with cat)without using a temporary file, you cannot make the file any smaller/larger without using a temporary file (there are a few exceptions to this).
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i think you need to use fstream f("temp.txt",ios::out | ios::in ), then it will work i think
mpk1979
|
|
|
|
|
I started a thread to perform some decoding function. This is to circumvent the problem of the windows not being able to be updated while the decoding is in progress. The code runs perfect for the first run i.e. it went through the file selection process to the completion of the decoding process.
However, when I want to decode a second file, an assetion failure occurred during or start of the decoding process. I narrowed down the bug to the 'decode' function in the thread function. Everything runs well second or third time with it commented.
Now I know that it is this function causing the problem. This piece of function was running fine when separately called and I went through it many times.
Appreciate if you could give advise on this issue. Any comment will be good.
Snippets of my code:
completed=false;
AfxBeginThread(DecodeThreadProc,pfilename,THREAD_PRIORITY_NORMAL,0,0,NULL);
while(!completed)
{
// Perform the windows update.
}
UINT DecodeThreadProc(LPVOID Paramfilename)
{
decode((char *)Paramfilename);
completed=true;
return 0;
}
searcher08
|
|
|
|
|
pFileName passed in to AfxBeinThreadProc must remain constant the entire time the thread is using the variable.
I suspect it might have been local to some other function calling AfxBeginthread, so you got into trouble there - it was invalid by the time the thread executed and tried to read it.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Thanks.
The pFileName was not amended by any function after the AfxBeginThread was called. Can I amend it in the Thread program.
I also noticed from the Memory usage monitor that the some memory was not released after the thread ended. I checked the code for errors in freeing pointers and there was no issue. Is there any way of releasing any memory used by the thread?
The thread was running fine for the first time. The problem only arises when it was loaded the second time.
|
|
|
|
|
It does not matter if pFileNAme is amended or not, I was concerned its lifetime did not outlast the thread.
Depending upon how a thread is called, especially in MFC, you might need to delete the CWinThread object after the thread has terminated, unless you set it to automatically delete itself.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
I did not do anything to the object. From the MSDN, I understand there is no requirement to end the thread as long as it is completed normally. I will heed your advise and proceed with the delete of the CWinThread Object.
Is this what it is suppose to look like?
CWinThread* ThreadHD = AfxBeginThread(DecodeThreadProc,pfilename,THREAD_PRIORITY_NORMAL,0,0,NULL);
delete(ThreadHD);
ThreadHD=NULL;
Many thanks for your advise. Greatly appreciated!
|
|
|
|
|
Yes, unless you set the auto delete member function.
This is safer...
CWinThread* ThreadHD = AfxBeginThread(DecodeThreadProc,pfilename,THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED,NULL);<br />
<br />
ThreadHD->m_bAutoDelete = TRUE;<br />
ThreadHD->ResumeThread();
This way, you don't have to wait for thread to exit before deleting ThreadHD yourself.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
I tried the method as advised. However, an error occurred at the delete(ThreadHD) line. I think that if the thread has exited, there should not be a need to delete it. Please advise. Thanks.
CWinThread* ThreadHD = AfxBeginThread(DecodeThreadProc,pfilename,THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED,NULL);
ThreadHD->m_bAutoDelete = TRUE;
ThreadHD->ResumeThread();
.
.
.
delete(ThreadHD);
ThreadHead=NULL;
|
|
|
|
|
The ThreadHD will delete itself! So you don't have to do it, that is why you got the assertion.
You only need these lines...
CWinThread* ThreadHD = AfxBeginThread(DecodeThreadProc,pfilename,THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED,NULL);
// m_bAutoDelete = TRUE allows a CWinThread to delete itself when the thread function exits
ThreadHD->m_bAutoDelete = TRUE;
ThreadHD->ResumeThread();
and REMOVE these lines from your code and the assertion will be gone...
delete(ThreadHD);
ThreadHead=NULL;
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Hey all,
I've been wanting to start a project for a while that involves several topics I have no knowledge on. One of those topics is communicating with a USB device in windows.
I have a Matrix Orbital 503c wich has a VK204-24-USB
(manual: http://www.matrixorbital.ca/manuals/VK_series/VK204-24-USB/)
Screen and im looking to build a small program to communicate with it.
So I have found several articles on this site about serial communications and my question is this: Is USB just another serial device or does it require a special kind of communication? Secondly since I have no experience with Hardware I/O does anyone have any suggested readings to give me some good beginners knowledge on the topic?
Thanks
-legit
|
|
|
|
|
legit wrote: Is USB just another serial device or does it require a special kind of communication?
No, USB doesn't work the same way as a serial port. Every USB device is shipped with a device driver. What you need to do is get a handle on this driver (with CreateFile) and then you'll be able to communicate with your device by sending IO codes to your driver (using DeviceIOControl) these codes should normally be documented with the driver (there are specific to your device).
Now, if the device you are using is a USB-to-serial module, then the driver simulate a COM port and you can use it the same way as a standard COM port.
|
|
|
|
|
Can you point me to the documentation for those functions ( CreateFile and DeviceIOControl)?
thanks
- legit
|
|
|
|
|
Anyone knows if and how I can hide my resources(like textures) in an executable file?
I mean if there is a way to hide my jpg file as a whole in an exe file
thanks in advance.
|
|
|
|
|
Lord_Vader wrote: Anyone knows if and how I can hide my resources(like textures) in an executable file?
I mean if there is a way to hide my jpg file as a whole in an exe file
you can use an exe protector like this http://www.codeproject.com/cpp/peprotector1.asp[^] it's simple but powerful!
Ali
|
|
|
|
|
Ali Mojtabaee wrote: uexe protector [...] it's simple but powerful!
Unless someone with knowledge scrutinizes your program.
These kind of software is like those stinging-insect repellants: Does not work 100%, and does only repell the harmless ones - those you could stand anyway.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi!
I'm starting to write an application (c++, mfc of course ) that has the primary task to show data from a database. Actually it isn't my first application written in c++ that access to a database to read data but probably it will be the most complex. For this reason I was wondering if you have some advice about the design of this kind of applications... On top of my worries there is how to manage queries: I'm sure that in the future there will be a lot of changes so, probably, my usual way (simply build a class "around" the structure of recordset's query) to manage this things could be limited.
So my question: there is something similar to the data abastraction layer that .net provides but for unmanaged code? There are some rules/advices that I should know? Any links to turorials, books and so on it will be really apreciated
Regards,
Francesco
P.S. I'm sorry if this post isn't exactly on topic with the forum. If you think that another forum could be a better choice let me know and I will move the question there.
|
|
|
|
|
I want to display each of the below variables in a separate line in a list box. I know I can use a separate InsertString for each one. But I wonder if there is a format command I can put in the ComplMessage.Format that will cause each one to go to a new line. I have looked at the format directives for sprintf, but don't see anything obvious. But sometimes it just isn't obvious. Any ideas? Thanks.
ComplMessage.Format("%d %s %s %c %d@%.4s %8s %d/%d %7s %d-%s",
orderDetail.XrefP,
orderDetail.ContractName,
orderDetail.ContractDate,
orderDetail.BuyOrSell,
orderDetail.Lots,
orderDetail.Price,
orderDetail.OrderID,
orderDetail.AmountFilled,
orderDetail.NoOfFills,
orderDetail.AveragePrice,
orderDetail.Status,
StatLine);
pListBox->InsertString(0,ComplMessage);
|
|
|
|
|
You can use edit box with multi line to instead listbox
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|