|
Hi all. Does it ever end? man. issue after issue I'll tell ya. ugh. Anyways, I have a problem performing the following:
if ((lResult = RegCreateKeyEx(HKEY_CURRENT_USER,"AppEvents\\Schemes\\Apps\\.Default\\.Default",
0,"",REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,
&hKeyResult,&dwDisposition)) != ERROR_SUCCESS)
printf("Failed\n");
if((lResult = RegSaveKey(hKeyResult,"reg.tmp",NULL)) != ERROR_SUCCESS){
printf("Failed\n");
}
The problem is I get the Key back properly, but when I try to save the Key so I can modify and set it back later on, I keep getting an error. The file does not exist when the error is returned. And I can't seem to find a simple way to get the error being returned
Any suggestions?? Thanks!
Dan Willis
|
|
|
|
|
Could you check the return value from RegSaveKey? It might give you a clue.
|
|
|
|
|
AlexO wrote:
Could you check the return value from RegSaveKey? It might give you a clue.
Just what I was going to suggest. Not sure about the ".Default" entries, but I assume they are kosher.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Yeah,
The error coming back is a 1314 system error, otherwise seen as:
"A required privilege is not held by the client. ERROR_PRIVILEGE_NOT_HELD "
I finally realized that after wards.
But that doesn't make any sense to me becuase I can still delete the registry key. How is it possible that I have privileges to delete it but not to save it?? makes no sense...
thanks guys.
Alex O, maybe I should just hire you. LOL you've helped me countless times.
Thanks
|
|
|
|
|
will1383 wrote:
ERROR_PRIVILEGE_NOT_HELD
That makes sense in light of this note in the docs:Windows NT/2000/XP: The calling process must have the SE_BACKUP_NAME privilege enabled. For more information about privileges, see Privileges. Follow the Privileges link in your documentation for a description of how to enable that priv.
--Mike--
PROCRASTINATION: Hard work often pays off after time, but laziness always pays off now.
BUY MY SOFTWARE!! (please?) RightClick-Encrypt - file encryption w/Explorer plugins | 1ClickPicGrabber - web page picture grabber for IE
My IntarWeb Homepgae!!!11
|
|
|
|
|
I have just a couple questions here... hopefully someone here can help me out.
1) I started a win32 API project, and saved my code in a *.c file, then I realized that I wanted to make use of some c++ stuff (objects), so I changed the name to *.cpp. Then, the next time I compiled the code, the following line started giving an error in the WM_PAINT section.
HBITMAP g_hbmDisplay = NULL;
HDC hdcMem2 = CreateCompatibleDC(hdc);
HBITMAP hbmOld = SelectObject(hdcMem, g_hbmBall); saying that "cannot convert a void * to struct HBITMAP__ *", even though, as a *.C file it worked perfectly.
2) Is it possible to have a *.c file and a *.cpp file in the same project and have the both of them work together, or is it a one or the other sort of deal?
3) What are the differences between windows programming in C vs C++ as far as the API is concerned? I dont need a very detailed exlanation, just a gist of what the differences are would suffice.
Thanks... I realize that it is probably annoying answering these questions, so if there is a recommended book on API programming in windows C++ that would also be appreciated.
|
|
|
|
|
SumGuy wrote:
cannot convert a void * to struct HBITMAP
just cast the result to HBITMAP : foo = (HBITMAP)SelectObject..
When history comes, it always takes you by surprise.
|
|
|
|
|
OMG, I can't believe that I didn`t think of trying that... I was always trying put the (HBITMAP) in the second parameter of the SelectObject(hdc, (HBITMAP) blah); If I would haver thought of that one, I could have went without wasting space on this forum...
thanks a lot, that's one less headache.
|
|
|
|
|
Re: #2 and #3
2.) Sure, you can have both 'c' and 'cpp' files in the same project. The linker only complains when you use a C-compiled function inside a C++ chunk of code. In that case you could use extern "C" {} wrapper in the C++ code.
3.) C programming for windows typically involves the Windows SDK without any wrappers to hide its complexity. There is no inheritance hiearchy to worry about so its easier to understand when you don't know object-oriented programming (OOP) so well.
C++ programming for windows involves understanding the inheritence mechanism and that, for instance, in MFC, a CDialog has its member functions *plus* the CWnd member functions and so on.
In general, C++ makes the implementation of a GUI a bit more compact and understandable with the condition that the person reading the code has OOP knowledge.
Yo, peace out!
|
|
|
|
|
So, from my understanding, c++ windows programming is basically MFC (or other custom libraries) whereas the C windows programming is more like the API code?
I have quite a bit to learn about the API before I can get into the MFC... I mean, I still can't figure out how to get a bitmap to show up on a button. So, yes... alot to learn.
|
|
|
|
|
SumGuy wrote:
So, from my understanding, c++ windows programming is basically MFC (or other custom libraries) whereas the C windows programming is more like the API code?
That's probably a common view these days. However before MFC, Windows developers also used plenty of libraries written in C. In many cases the libraries (C or C++) are wrappers for API functions, most of which are written in C.
A couple of time-tested standard references for Windows development are:
For API: Programming Windows, Charles Petzold
For MFC: Programming Windows with MFC, Jeff Prosise
For MFC, I also recommend:
Visual C++.NET Bible, Tom Archer (CodeProject Favorite Author)
Professional MFC VC++6, Mike Blaszczak
MFC Internals, George Shepherd
When considering Windows libraries, don't forget STL is very useful and very common in the Windows world. Also near the top of my list is ATL. With the changes (improvements) made to ATL in the .NET release, it is not just for COM builders anymore. (Not that it truly ever was!)
NONE of these books are cheap! (Esp. outside the US) But all are available in the used book market and can sometimes be found in larger public and university libraries.
marshall
If you continue to do the same things you always did, don't be surprised if you get the same results you always got.
|
|
|
|
|
Hi. I have a dailog based app and I want a popup dialog to set the text in the controls on the main dialog. How can I acomplish this without the program malfunctioning?
-- Steve
|
|
|
|
|
OK. I want to send a message from one dialog to another. How do I do that?
-- Steve
|
|
|
|
|
Pass a ptr for the main dialog to the popup dialog. Or in the popup dialog use GetParent() or something like that.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
i guess that your question is about creating a new dialog window and then change the main dialog window text from this one.
To do this create a new dialog("newdlg") then create a new class("newwin") for it setting CDialog as the base class.
Now create a class variable "x" of the type "newwin" in the definition of the main dialog window.
Add a button in the main window and edit its code as :
x.Create("newdlg",this);
x.Showwinodow(SW_sHOW);
Now you can get the status of button/edit boxes in the new popup window by
using the class member format. eg if the edit box in the popup window is "ys"
then do something ..
it could be implemented as
if(x.listboxstring = "ys)
{
do something ....
}
i hope this may help you to get started.
|
|
|
|
|
I want to postmessage my parent View when the CDialog it spawns is moved/resized. SO I put in the WM_ON_SIZING handler in the CDialog and when I debug it doesnt ever step into the OnResizing function even if I resize/move the CDialog....so I even tried putting my postmessgae in Onsize (*except I'm not changing its size, just the location....and it didnt step into OnSIze either (just moving not resizing...)
Help!
Appreciate your help,
ns
|
|
|
|
|
What messgage is sent when I move and or resize a window? What function do i Need to pinpoint he fact that I moved, dynamically?
Appreciate your help,
ns
|
|
|
|
|
And it tells me that WM_MOUSEMOVE is issued...but thats if I move the mouse anywhere on the dialog. No other message is there in the running list...
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
I want to postmessage my parent View when the CDialog it spawns is moved/resized.
Why?
To find out if a window moves try checking WM_MOVE, and/or WM_SIZE.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Why ? Because the parent remembers the location and size of the CDialog even after its dismissed and a new one is created later at the same location..also to save info to th eregistry at the end..
Thanks so much for the help!
|
|
|
|
|
|
I got my problem resolved. I'd never used WM_MOVE before. As for the OnSizing, I was expecting it to fire if I just moved, but not resized. Which was the wrong function to look at for simply moving....
Thanks. Learned a lot!
|
|
|
|
|
I need to know if I am understanding this properly:
If I want to display the time (in text) for a given number of seconds (dwSec) since Jan1, 1970 (in UTC), would I need to adjust the dwSec for the difference in time zones first before calling CTime::Format()?
Does this look right?:
DWORD dwSec = 1045688797; //Feb 19 21:06:37 2003 UTC (I think)
CTime tLoc((time_t)dwSec);
CString szLocal = tLoc.Format("%m/%d/%Y %H:%M:%S");
//Adjust for time zone diff before calling CTime::Format
//for UTC in text format:
dwSec += (tzinfo.timezone * 60);
//Adjust for DST:
if (tzinfo.dstflag)
dwSec -= 3600;
CTime tUTC((time_t)dwSec);
CString szUTC = tUTC.Format("%m/%d/%Y %H:%M:%S");
If there is a better way, I would appreciate any tips, but I still need to know if the above is correct.
Thank you very much.
|
|
|
|
|
I am wondering where I should put the On_WM_SIZING :
afx_msg void OnSize(UINT nType, int cx, int cy);
<code> afx_msg void OnSizing( UINT nSide, LPRECT lpRect);</code> here????
afx_msg void OnGetMinMaxInfo(MINMAXINFO* pMMI);
DECLARE_MESSAGE_MAP()
<code> afx_msg void OnSizing( UINT nSide, LPRECT lpRect);</code> or here????
Similarly:
BEGIN_MESSAGE_MAP(CResizeableFileDialogParentWnd, CDialog)
ON_WM_SIZE()
<code>ON_WM_SIZING()</code>
ON_WM_GETMINMAXINFO()
<code>ON_WM_SIZING()</code>
END_MESSAGE_MAP()
Appreciate your help,
ns
|
|
|
|
|
Anytime you edit the message maps manually, put your changes outside the //{{AFX //}}AFX section to avoid breaking ClassWizard.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|