|
Hi,
I made a worker thread in my program, and i used CDaoRecordset::GetFieldValue function in the thread.
But every time i got access violation error
Does CDaoRecordset class support threads ?
It's my source code:
while( !theApp.m_EleTele.IsEOF() )<br />
{<br />
pDlg->dwRecords.Add( theApp.m_EleTele.GetAbsolutePosition() ); <br />
pDlg->m_List.AddString( theApp.m_EleTele.GetFieldStr( pDlg->strField ) );<br />
theApp.m_EleTele.MoveNext();<br />
}
GetFieldStr is made by myself and it returns string.
Regards,
Hadi
|
|
|
|
|
If I want to open a modal dialogue in one of multi-thread app, how can I realize this?
......
dlg.DoModal();
......
Thank you in advance!
LeonOrient
|
|
|
|
|
See this article[^] in the MSDN on creating user-interface threads. You can call dlg.DoModal() in the InitInstance member function of your thread class.
Software Zen: delete this;
|
|
|
|
|
If I want to call DoModal function in my normal funcion of my thread class, how to do with this?
Thank you very much!
|
|
|
|
|
It sounds like you want to display a dialog in a worker thread. That doesn't work, because a dialog, like all windows, needs a message pump, which worker threads don't have.
Software Zen: delete this;
|
|
|
|
|
Can I send a message to handle a modal dialogue?
Can you commend a multi-threads sample for me?
Thank you!
|
|
|
|
|
Hi all,
I have problem, i got some drawings/shapes connected with lines(like network) and I want to drag and drop one shape from one place to another, but with this, the lines (thats are connected) should also be move
any ideas/comments will be appriaciated.
thanks
|
|
|
|
|
I have a static control on a dialog that I want to paint icons onto. So I have overridden the OnPaint method and have the following code.
m_StyleHeaderFrame is the member variable linked to the Cstatic control.
IDB_TOOLBARICONS is my resource handle to my bitmap with icons.
<br />
void CNewCharacterPage5::OnPaint() <br />
{<br />
CPaintDC dc( this );
HICON hIcon;<br />
<br />
CDC memDC;<br />
memDC.CreateCompatibleDC( &dc );<br />
<br />
if(m_hWnd && !PaintOnce)<br />
{<br />
pToolbarImages.Create(IDB_TOOLBARICONS, 14, 2, RGB(255, 0, 255));<br />
PaintOnce = true;<br />
}<br />
<br />
CRect rcClient;<br />
m_StyleHeaderFrame.GetClientRect( &rcClient );<br />
rcClient.OffsetRect(-24, 0);<br />
hIcon = pToolbarImages.ExtractIcon(4); <br />
memDC.DrawIcon(rcClient.right, rcClient.top, hIcon);<br />
rcClient.OffsetRect(-24, 0);<br />
hIcon = pToolbarImages.ExtractIcon(1);<br />
memDC.DrawIcon(rcClient.right, rcClient.top, hIcon);<br />
}<br />
Everytime I run the project the CStatic control paints blank. Does anyone know why?
Thanks!
|
|
|
|
|
You only made the memDC compatible to the "dc". You must bitblt the memDC onto the dc to disply it.
|
|
|
|
|
dumb question, but are you sure? I'm not really dealing with Bitmaps and bitblt deals with bitmaps. I tried using it anyways to see if it would work and it didn't change anything.
I do have one bitmap, but I am extracting out icons from that one bitmap and wanting to display them like one would on a toolbar except for me I want them on a static text control. Exactly like the presentation you see in VC++ when you go to Project->Settings->pre-link step. There you see the four icons on the static text control.
Going after the same thing.
I realize there is code out there that does this very thing but that code is very advanced for me and I'm trying to simplify it the best I can. Unless there really is code out there that is simple to understand for the intermediate designer. I could have sworn I saw something a long time ago that did pretty much I am stuggling to attempt, with ExtractIcon and DrawIcon, but I cannot find that code any longer, my mind totally forgot, and I lost my original code.
Thanks!
|
|
|
|
|
You are creating a compatible memory DC. You are doing stuff on it. You need to take this and bitblt to the CPaint DC. Take a look at the Bitblt function.
|
|
|
|
|
whew! Hmmm... well I tinkered with Bitblt. Tried quite a few variations on a theme, poked around other examples and still can't seem to make this work.
Here is the code I finished with
<br />
CPaintDC dc( this );
HICON hIcon;<br />
<br />
CDC memDC;<br />
memDC.CreateCompatibleDC( &dc );<br />
<br />
if(m_hWnd && !PaintOnce)<br />
{<br />
pToolbarImages.Create(IDB_TOOLBARICONS, 14, 2, RGB(255, 0, 255));<br />
PaintOnce = true;<br />
}<br />
<br />
CRect rcClient, rcOriginal;<br />
m_StyleHeaderFrame.GetWindowRect( &rcClient );<br />
ScreenToClient(&rcClient);<br />
rcOriginal = rcClient;<br />
<br />
rcClient.OffsetRect(-24, 0);<br />
hIcon = pToolbarImages.ExtractIcon(4);<br />
memDC.DrawIcon(rcClient.right, rcClient.top, hIcon);<br />
memDC.BitBlt(rcClient.right, rcClient.top, rcClient.right+24, rcClient.bottom, &memDC, 0, 0, SRCCOPY);<br />
<br />
rcClient.OffsetRect(-24, 0);<br />
hIcon = pToolbarImages.ExtractIcon(1);<br />
memDC.DrawIcon(rcClient.right, rcClient.top, hIcon);<br />
memDC.BitBlt(rcClient.right, rcClient.top, rcClient.right+24, rcClient.bottom, &memDC, 0, 0, SRCCOPY);<br />
<br />
dc.BitBlt(rcOriginal.left, rcOriginal.top, rcOriginal.right, rcOriginal.bottom, &memDC, 0, 0, SRCCOPY);<br />
Did I use BitBlt correctly or have I messed up on that too?
Thanks for the help!
Chris
|
|
|
|
|
You know my computer just died on me and I am using another computer without MSDN etc. But to begin with, the variables for the Bitblt for the third anfd fourth variables should be width and height. I am not quite sure what coordinates you are using. for rcOriginal and rcCLient.
You know also, I think you need to create a compatible bitmap and loaded it in. Try a search for CMemDC for no flickering solution. You will fins it very useful and a good example.
|
|
|
|
|
Here is a compiling result:
fatal error C1019:
unexpected #else
The position is at "#else" below:
#ifndef NOT_USE_PRECOMPILED_HEADER
# include "StdAfx.h"
#else
# define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
# include <afxwin.h> // MFC core and standard components
#endif
What is wrong?(I used VC6)
|
|
|
|
|
When you are using precompiled headers, the compiler skips everything up to the specified header file. The compiler doesn't preprocess or parse what it skips. In this case, it's skipping everything up to and including the line #include "StdAfx.h" . The first line it sees is therefore the #else , hence the error message.
What are you trying to accomplish by making the precompiled header conditional?
Software Zen: delete this;
|
|
|
|
|
This is not coded by me.
I use it as a class to format foppy disk.
But when compiling my project I found this error,
in the meantime I don't know it too much.
So I want to need a help here.
Now I have displaced it with "#include <stdafx.h>"
Altough I can run my project(in multi-threads), a warnig dialogue
is popped up, saying:"You do not have sufficient rights to perform this operation",when call "DoModal" funtion and reach here:
FormatResult = (*dl_SHFormatDrive)( hWnd,cDrive - 'A', SHFMT_ID_DEFAULT,bQuickFormat?SHFMT_OPT_FULL );
Why is this do you know?
|
|
|
|
|
I am trying to find a way so that not so many file header must be included when I want to use a class from a DLL from a class that has many other headers included. All I know is that when I inlcude one header everything included in it must be included etc. This creates really quite a chain. Any way out of this I do not know.
For one of these situations, I am including a MODELESS dialog in a class. Because the way I am doing it now is to include a pointer to it in the declaration I have to include the header in the main class header. I want to move the header inclusion to the .cpp file. I was thinking about making a global declaration in the .cpp file. Then just create it by new etc. This would be for the entire duration of the program. I do not want to make it modal because that would disrupt the other parts of the program which has to run during this. If multiple programs call this DLL, would this still work?
Would another better way be just to call it modally then call peek and translatemsg etc in that function call?
Anyone know more ways to "hide" the header files so that it does not have to be included for DLL but can be hidden in the .cpp file?
Thank you in advance.
|
|
|
|
|
If I understand you correctly, you need to make use of forward class declarations:
class CDLLClass;
class CYourClass
{
CDLLClass *m_pDLLClass;
}
#include "YourClass.h"
#include "DLLClass.h"
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
HI Roger.
You mean to forward declare it as you did, I do not have to include the header file that particular class in the header of the class that use it? This way I do not have to include it in the project that calls the DLL? For variables that are pointers you can do this. Any other means to help reduce the amount of files you have to include in the caller of the DLL?
Thanks.
|
|
|
|
|
I want to run my program at start up,so I set the registery key HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run for doing this.But I want my users can change the setting so my program may run at start up for some users. How can I handle it that it does not run for some users?
Thanks
Mazy
No sig. available now.
|
|
|
|
|
There are several solutions. One solution is for the program to determine the active user upon startup.
Kuphryn
|
|
|
|
|
kuphryn wrote:
One solution is for the program to determine the active user upon startup.
Could you please explain it more?
Mazy
No sig. available now.
|
|
|
|
|
Use the same key but under HKEY_CURRENT_USER.
Regards
|
|
|
|
|
But there is a problem with that.It should run for all users at the first installation,then uses can change it.If I use that it will only run for the user that install it and will not run by default.
Mazy
No sig. available now.
|
|
|
|
|
Use that key, but make your program check some value under HKEY_CURRENT_USER that the user can use to specify whether the program is to run. This way the program run for all users, but if the user-specific key is set to some value, then exit immediately. If the user-specific key does not exist, then just continue as normal.
Hope this helps
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"
|
|
|
|