|
Either subclass your own edit control and do the filtering there, or be lazy and search and download source for a masked edit control. There are plenty of those around on a website near you.
Edit: Spelling
|
|
|
|
|
can anybody explain how can i read from a file in CString onject using fstream.
CString str
fstream fin
fin.open(^);
fin.read((char *)str.GetBuffer(0),str.GetLength()* sizeof(TCHAR));
fin.close
this code is not working while m able to write the same way in file but not able to read
fin.write((char *)str.GetBuffer(0),str.GetLength()*sizeof(TCHAR));
plz help thank u
|
|
|
|
|
You must specify a proper length .
How many bytes do you want to read?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
well i cant depict that before as it is a path.and may change in my application. so i dont knw about its length
|
|
|
|
|
You have to specify a length.
That is why that parameter exists in the read function.
I think you should first read it using a normal array. (Without CString).
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
In that case, you should probably read a character at a time, adding them to the CString , until you reach some character that indicates the end of the path.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Two things I see, your read:
fin.read((char *)str.GetBuffer(0),str.GetLength()* sizeof(TCHAR));
str.GetLength() in this case will be 0 since the string is empty, so you're telling the read to get 0 characters!
You most likely know the maximum size you need, in which case you can use something like
fin.read((char *)str.GetBuffer(1024),1024 * sizeof(TCHAR));
You must also call str.ReleaseBuffer(), and if the data you read is not null terminated, you'll need to set the length by using
str.ReleaseBuffer(iBytesRead);
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi All,
I am creating one popupdialog from mainwindow. The dialog gets poppedup and iam using one timer function to popup. I am using one edit control in mainwindow . My problem is after getting poppedup the focus on the main window loses and also on the edit control in mainwindow. How to avoid this stealing of focus by a popup dialog??
Regards,
Spk
|
|
|
|
|
When I click a hot key combination (Ctrl+Shift+P) my program do copy some text to the clibboard,
So I can paste it to any window by holding Ctrl+V
Now I like to automate this and be able to do the Ctrl+V programatically,
Lets assume I just want to paste just anything to other windows - so I can get started,
I have tried this, but I guess I'm missing something:
SendMessage(WM_PASTE, 0,0);
also tried:
BroadcastSystemMessage(BSF_POSTMESSAGE | BSF_IGNORECURRENTTASK,
BSM_ALLCOMPONENTS,
WM_PASTE,
(WPARAM)NULL,
(LPARAM)NULL);
I'd like to broadcast a "paste" message (or "Ctrl+V") so I will not have to find the current active window and get its focus,
Any suggestions ?
Best Regards - Yovav Gad
CEO and founder of MicroMighty, Inc.
modified on Thursday, April 2, 2009 11:58 PM
|
|
|
|
|
I tried something similar a few yeras back to aid in filling in forms that required the same data over and over, and as far as I can remember, different applications needed different handling. You have to try sending keystrokes to some, and WM_PASTE to some, and some applications do not even use a window, but a custom made input and cannot be manipulated at all.
Sorry, but to my knowledge there is no universal method that works everywhere.
|
|
|
|
|
Yea, you are probably right,
I made some progress, however - it only works in some places (like notepad...)
POINT pt;
GetCursorPos(&pt);
CWnd* editControl;
editControl = WindowFromPoint(pt);
editControl->GetFocus();
editControl->SendMessage(WM_PASTE, 0, 0);
I also tried to programatically click Ctrl+V and cause a paste like this:
::SendMessage(GetForegroundWindow()->m_hWnd, WM_CHAR, 22, 0x56);
But it seems to have the same problem - only works in some places (like notepad...)
I wonder how can I better send the Ctrl+V and make the window/control think he got Ctrl+V clicked and do the paste for me (to which ever CEdit / CView control being used)
Please let me know if you have any suggestions.
Best Regards - Yovav Gad
CEO and founder of MicroMighty, Inc.
|
|
|
|
|
Yovav wrote: I wonder how can I better send the Ctrl+V...
Have you tried keybd_event() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
In addition to Niklas' comments, I can see another problem.
I'll pretend your idea works. You would then make EVERY top level window receive a paste message, so they'd all perform a paste. That includes explorer, Invisible windows controlling tray notification icons... And that may be a BAD THING(tm).
Is it really so bad to have the user in control of their own PC? They spent the money on it, after all...
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Well, its not really a problem - because I am sending the "WM_PASTE" message only to that specific control on which the user had put the cursor on,
POINT pt;
GetCursorPos(&pt);
editControl = WindowFromPoint(pt);
editControl->GetFocus();
editControl->SendMessage(WM_PASTE, 0, 0);
Also - the user is not going to lose control over anything,
This program gonna help users run and paste data exactly like they want it.
Best Regards - Yovav Gad
CEO and founder of MicroMighty, Inc.
|
|
|
|
|
Iain Clarke wrote: Is it really so bad to have the user in control of their own PC?
Well, yes and no . In my specific case my friend got so tired of filling identical data (like company name and address) in some text fields over and over so I offerd a way to just put the cursor in the right place and hit a user defined short-cut-keystroke, et voila: User defined text -> clipboard -> edit control.
I'm just saying there could be a good reason for doing this.
|
|
|
|
|
Well, my comment was more about the broadcast idea...
I'll trust your domain expertise on this though. Or you mercenary desire for a customer to give you money!
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Niklas Lindquist wrote: I'm just saying there could be a good reason for doing this.
And calling BroadcastSystemMessage() is not a solution for that reason.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I don't understand exactly how the WM_PASTE message is getting picked up,
but it might be safe to broardcast it everywhere if it only getting picked up in one place where the cursor and focus is,
remember - my intention is to let the user who already have his cursor focused on some text control to paste specific data, but the user must put the focus first before it will do anything...
Best Regards - Yovav Gad
CEO and founder of MicroMighty, Inc.
|
|
|
|
|
The huge array my algorithm need may be contain more than 2^100 struct elements.I don't know how to solve.
|
|
|
|
|
There is no question, so the only thing I can do is provide a comment. Here it is:
an "algorithm" that needs more memory than any reasonable system can hold, is not an algorithm at all. It is a kludge.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I'm not sure Alan Turing would agree
|
|
|
|
|
Actually,this algorithm is just for a theoretical system.
|
|
|
|
|
The only thing that might help is sparse arrays[^] (if a lot of your array elements are some null value).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I can't find any element could be ignored.
|
|
|
|
|
That's 1,267,650,600,228,229,401,496,703,205,376...
Are you doing a simulation of all of the fundamental particles in the universe?
And a 64bit processor isn't going to help you either. If each element took a byte, thats 1,267,650,600,228,229,401 Terabites (using vendors definition!) Assuming you had a bunch of terabite drives in RAID999, and each drive takes 10cm x 2cm x 20cm, you could fit 10x50x5 (in a cubic metre. That's with no cables or packaging.
So, 507060240091291760 m^3. Now, a container can hold approximately 75 cubic metres. Let's Assuming you squich it really hard to 100m^3. That's 5070602400912917 containers.
Looking at http://en.wikipedia.org/wiki/Container_ship[^], the largest container ship displaces 157,000 tons of water. Which is 157,000 cubic metres of cargo (assuming the boat is made of plywood). Thats 3229683057906 of these container ships.
Let's assume your local port can handle ten of these ships every ten hours, so averaging one an hour. It would take 3686852 centuries to just deliver this to you.
If they just delivered the last one now, they'd have had to start manufacturing them a 1/3rd of a million years BC.
I think you need to take another look at your algorithm, before I have to calculate how much mass you'd have to destroy in a matter-antimatter collider just to power the hard drive array for an hour.
Iain.
(Can you tell it's lunchtime?)
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|