|
alright, ill keep messin with it, thx a million!
if u have the time/desire, i can email u the code.
|
|
|
|
|
Ryan2845 wrote:
alright, ill keep messin with it, thx a million!
Good luck Ryan
Ryan2845 wrote:
if u have the time/desire, i can email u the code.
Thanks, if you figure out what went wrong, lemme know too
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Hello,
I am using CDatabase from within a service. The CDatabase is used from within multiple worker threads. So far I haven't run into trouble, but I don't want to go ahead and then have to come back and debug my base code. Has anyone else used CDatabase in a multithreaded service program?
Regards
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
I have and you should be ok.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Tom Archer wrote:
I have and you should be ok.
Whew, that is a relief. I was getting a little apprehensive and the tension grew cause I got no replies even after a couple of hours.
Thanks Tom.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Well, isn't the MFC library thread safe altogether? Why CDatabase should be different?
Best regards,
Alexandru Savescu
|
|
|
|
|
Alexandru Savescu wrote:
Well, isn't the MFC library thread safe altogether?
Actually no! A good number of MFC classes are not thread safe
Glaring examples are CSocket and even CWnd. Try calling UpdateData on a CWnd derived class from a thread that didn't create the CWnd and you'll see how MFC is not thread-safe
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Well I do not know if calling UpdateData from another thread means that MFC is not thread-safe. The first thing you are told when writing multi threading apps is that you must not touch the GUI objects created by another thread.
Every thread has its message pump and all controls created by that thread receive notifications in that pump. Calling UpdateData from the second thread will post the messages in a different message pump (the second one) and your app will crash. This does not mean that MFC is not thread safe.
I don't know about CSocket though.
Best regards,
Alexandru Savescu
|
|
|
|
|
Sorry for such a lame question,
but I am creating a Modeless dialog from my CMainFrame class. The window is indeed modeless, but when I change the focus back to the main (parent), the modeless dialog remains on top.
How can I have my modeless dialog move to a lower level on the desktop whenever I change the focus to another window?
Thanks for answering my "common" question.
Humbly,
Johnny
|
|
|
|
|
make the modeless dialog's parent wnd NULL (ie. the desktop). that way, it can float anywhere it wants to.
-c
I don't care, and you can't make me.
|
|
|
|
|
This is because your dialog is a child of the frame window. Make it a child of the desktop.
This might also help:
http://www.codeproject.com/useritems/gettingmodeless.asp
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Or if you want to still make it a child of the Mainframe for some reason, you can in OnActivate check if it is being deactivated and just hide it at that point. This means that if you press the mouse outside the dialog box, it will hide.
|
|
|
|
|
Stan the man wrote:
This means that if you press the mouse outside the dialog box, it will hide.
This will mean that to bring it up again [make it visible], the user might have to be offered some button or menu item.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Very True. I guess I have always had a button to do this.
|
|
|
|
|
Thanks to all answers - see below.
Using the following did exactly what I desired:
m_pSetupDlg->Create(IDD_SETUP, NULL); // NULL associates to desktop.
Thanks again. Keep up the good work.
Johnny
|
|
|
|
|
I have a char array defined as
char cBuffer[200]
and I want to convert this to a double.
Can anyone help with the syntax to do this?
Thanks,
Kyle
|
|
|
|
|
use:
double dblVal;
sscanf(cBuffer, "%lf", &dblVal);
|
|
|
|
|
If you mean you have a double in the first 8 bytes of the array then you can get at it like this:
double dbl = *((double*)cBuffer);
or alternatively if the bytes that contain the double start say 6 bytes into the array then the syntax is nearly the same but you need the address of the first byte of the double:
double dbl = *((double*)&cBuffer[5]);
Just one thing to be careful of is that x86 cpu's allow this casting from anywhere in memory but some cpu's have strict rules about things being aligned on even byte boundaries so if portability is important then you may need to copy the bytes using memcpy() or something first to ensure the proper alignment.
Matt
|
|
|
|
|
Casting it to double?
Or converting the contents to double?
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Converting the contents to double describes it well.
Kyle
|
|
|
|
|
kyledunn wrote:
Converting the contents to double describes it well.
Then the solution is elementary.
Use atof(...)
double num = atof(buffer);
Hope that helped,
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Yes, that did help. Thanks.
Kyle
|
|
|
|
|
How do you serialize an MFC POSITION data type and an HTREEITEM?
This questions from my dad. He told me to post it here so I can't get anymore detailed until he gets home.
-Raffi's dad
|
|
|
|
|
you don't. you find some other way to represent them. a POSITION is, well, probably just a number, an ordinal. an HTREEITEM is much more complex. if you want to serialize a tree, use something like XML, or come up with your own tree-like data structure.
-c
I don't care, and you can't make me.
|
|
|
|
|
Hey folks,
I've got a problem that I need help with, I've tried numerous approaches an have yet to find a "WHY" answer.
Some background..
In our product, which is just a big database, we've got our MAIN process which owns a big chunk of memory which holds all the TABLES, and various child processes which have READ ONLY access to those tables. All updates are done using a DATA-MANAGER thread in the MAIN PROCESS, where a child process will send a message to the MAIN process thread, telling him to update TABLEx, RECORDx, FIELDx with value Y, No problems...
We have 5-6 tables in the MAIN process which need to be READ_WRITE for all the child processes. This works fine in Windows 95/98/NT/2K, but in Windows XP, we're finding that child processes do not have READ_ONLY access to this memory.
Is anyone aware of any changes done to VirtualProtect in Windows XP?
Basically, when the memory is created/mapped in the MAIN process, we mark the memory area as PAGE_READWRITE... When we start a child process, we Map the same memory as PAGE_READONLY initially(OpenFileMapping, MapViewofFile) for the child process. Like I mentioned earlier, we have some tables that are LOCAL tables that do not go through the DATA-MANAGER-THREAD (which makes the update, then broadcasts it to the server app, etc, etc), that need to be READ-WRITE for the child processes.
When we populate the tables from the child process, if we encounter a table that's LOCAL, we change his permissions to PAGE_READWRITE:
if ( pcos->objc[*pclass].sync == LOCAL_TABLE )
VirtualProtect ( addressstart, size, PAGE_READWRITE, &prot );
In Win 95->2k, this works fine, VirtualProtect returns 1 (SUCCESS)... in XP, we get a 0, and a GetLastError(), as 47 (I think... INVALID_PARAMETER)...
For fun, we did a switch-eroo... We made the tables INITIALLY READ-WRITE for the child process, then made all tables that were !LOCAL_TABLES READ-ONLY... Fired up XP, BINGO, everything worked fine...
Is there a new rule in XP where you cannot UPGRADE the permissions when using a shared memory area, but only downgrade?
READONLY -> READWRITE failed, but, when we did the switcheroo
READWRITE-> READONLY, it worked...
Thoughts? Anyone have any direction here? Much Appreciated..
Mike
doner@obtain.com
|
|
|
|