|
|
<br />
DWORD dw = 0;<br />
CRegKey rk;<br />
rk.Open(HKEY_CLASSES_ROOT,".txt");<br />
rk.QueryValue(dw,"(Default)");<br />
rk.SetValue("wordpad.exe","(Default)");<br />
rk.Close();<br />
The above code has no error but does nothing.
What should I change in my code to set the file extenxtion's associate.
In this example,use wordpad.exe when printing .txt files.
|
|
|
|
|
Hi,
I kniow the name of the registry parameter I want to read,
But....
How do I read it in MFC ?
Shay
|
|
|
|
|
http://www.codeguru.com/forum/search.php?s=&action=showresults&searchid=636677&sortby=lastpost&sortorder=descending
|
|
|
|
|
|
Ok, so a few years ago, someone posted an Onscreen Keyboard here that was written in MFC, and it typed text into other windows by grabbing the handle under the top window in the zOrder, and sending keystrokes using keybd_event() to the handle. It works, except not well. If you try it in IE, for instance, when you click out of the window and back in, the text comes back as selected, so you can't type more than one character, because when you give focus back, the character is selected, then you send the keystroke, and the character is overwritten. Does anyone here have any ideas how to make it so you click on the keyboard, but the edit control never loses focus?? Seems like a lot to ask, but there are a lot of keyboards that do this out there...
|
|
|
|
|
Try setting a WH_CBT hook to trap any focus changes, and prevent the focus changing to the keyboard window. Look at the documentation for SetWindowsHookEx() and CBTProc() . You'll need to check if the hook is being called because of a focus change (nCode == HCBT_SETFOCUS) and prevent the focus change (by returning 1) if the window handle (the wParam value) represents the keyboard window.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I am working on an application that works like a text editor, but includes special objects that, when clicked, display a selection of text with which it will replace itself. The app uses rich edit, of course (MFC). I doubt activex will work here, and even if it will, I can't figure it out, so if that is the answer, I will need help.
What I originally did was use the control's protected formatting to seperate those objects from the rest of the text, and used the object's protected text as its name to keep track of it (aka, the object 'objObject' would read objObject in the text). That worked well, till I realized that when I select something to display (when in the mode that does that), I lose track of its identifying text. I have to keep track of which object is which, since it manages the behavior of the object (of course).
Since I am going to be changing the text, I cannot rely on that. I attempted to extend the CHARFORMAT structure with my own variable, so that I could keep track myself, but to no avail (perhaps I did it wrong - anybody else gotten that to work?). I also tried using CHARFORMAT2, but I didn't get that working either.
Any ideas? Thanks.
Fight till it kills you.
|
|
|
|
|
Perhaps a better question is, how do I create my own formatting?
Fight till it kills you.
|
|
|
|
|
Paul Frazee wrote:
how do I create my own formatting?
With great difficulty. The Rich text control doesn't support custom drawing/formatting. Practially the only way you can do it is to rewrite the control from scratch. That's one of the things I'm in the process of doing at the moment, although I haven't done much yet.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
That doesn't sound very pleasant. I decided to test what would happen if I did put in a tag that is not standard, what would happen. No visible change occured, which means I _could_ potentially add my own tags. The trick is to write a good custom formatting system - knowing if the formatting is active, and setting it successfully. I figure that could be done if you could get the position of the current selection in the unformatted text (with tags), but I can't figure out how to do that effectively. Any thoughts?
|
|
|
|
|
PaulFrazee wrote:
Any thoughts?
I'm fairly sure that the richedit control would remove all unknown tags, although I'm not positive. It might be easier to keep track of your custom formatting using an array with the the position and length of the text that the formatting represents. I have no idea how you would actually draw this custom formatting - the richedit control draws all or nothing.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thankfully, no special drawing is required. I suppose I could keep track by position and length, but then every time a change is made to the file I have to track those changes. I suppose if I just intercepted every char and cycled my array, adjusting every following position accordingly it would work... blast you microsoft!
Fight until it kills you.
|
|
|
|
|
PaulFrazee wrote:
I suppose if I just intercepted every char and cycled my array, adjusting every following position accordingly it would work
Yep. That's what I'd do, except that I'm writing a fully custom one - I require special drawing - transparency, shadowed text, vertical text etc. It's gonna be a horribly long job, but well worth it - I've yet to see any decent free alternative to a rich edit control.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Well sweet. Email me when you finish, eh?
|
|
|
|
|
I'll post it as an article
But don't hold your breath. It will take a while - I can only work on it at night
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hello,
In the past I have always used CArray.. I want to get away from it and start using STL's vector.. I bought a book “STL Programming from the ground up” by Herbert Schildt. After reading the first few chapters I realize that it't pretty easy to use vector.. My question is how do I create an array/vector of structures (The book doesn't have any examples that I have found so far). Here’s what I've tried.. and obviously it doesn't work.
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
// My ports struct..
struct s_Ports
{
int iPort; // Default Port #.
int iFilePort; // File Transfer Port #.
};
int main(int argc, char* argv[])
{
s_Ports p;
p.iPort = 20;
p.iFilePort = 21;
// How do I do this??
vector <p,&p> vec(10);
return 0;
}
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
you can define a vector multiple ways, one way (the way i use) is:
say you want a vector of doubles, called 'values'
vector<double> values; //
to add values to the vector, use
<br />
double number = 34.657;<br />
values.pushback(number);
your book should include a lost of STL commands to do, popback, erase, size, etc.
*.*
|
|
|
|
|
try
vector<s_Ports> vec(10);
John
|
|
|
|
|
Doh..
I knew it would be something stupid..
Thanks!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I have the same book. STL will take a while to get used to but once you grasp the concepts it becomes a very valuable programming tool. However, I still do have to look up a thing or two in that book and this seems to happen only when I leave it at home...
John
|
|
|
|
|
I am having problems declairing a vector in my header.. I want it to be a member variable of my dialog class.. I have included <vector> in the header.. but it gives me 18 errors when I try to compile.
in my test dialog header I have..
#include <vector>
class CTestDlg : public CDialog
{
// Construction
public:
CTestDlg(CWnd* pParent = NULL); // standard constructor
vector<int> v_test;
vector<int>::iterator iter_test;
.... etc....
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
etc......
Any idea why it wont compile?
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
At first I did not have a clue but I tried your application and it failed for me in the same way. Then I figured out the problem. Either put
using namespace std;
before your class definition or preface vector with std::
std::vector<int> v_test;
std::vector<int>::iterator iter_test;
John
|
|
|
|
|
Thanks,
Shortly after I posted the problem.. I figured it out..
THanks again for all your help!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
You apparently forgot to specify STL namespace try adding
using namespace std;
or
using namespace std::vector;
before the class declaration or changing your vector variables to
std::vector v_test;
std::vector::iterator iter_test;
Regards,
Denis
|
|
|
|