|
Have you read this article. I believe it explains all you should need to know.
|
|
|
|
|
I'm working on an (AI) agent for my browser, thats explains why I want it runing in a thread, and I'm accessing a global CStringArray(loaded at start up), why does it crash when I try to access it?
DWORD CBookmarks::BKOrg_ThreadStub(DWORD arg)
{
return ((CBookmarks*)arg)->BKOrg_Thread();
}
DWORD CBookmarks::BKOrg_Thread()
{
::MessageBox(GetSafeHwnd(),"Start","Thread",MB_OK);
::MessageBox(GetSafeHwnd(),m_strStr_Websites[0],"Threads",MB_OK);
// ::MessageBox(GetSafeHwnd(),GetFiles(m_strStr_Websites[0]),"Threads",MB_OK);
::MessageBox(GetSafeHwnd(),"Ended","Thread",MB_OK);
AfxEndThread(0);
return 0;
}
void CBookmarks::StartBKOrg_Thread(void )
{
pThread=AfxBeginThread((AFX_THREADPROC)&BKOrg_ThreadStub,(void*)this);
}
But when the MessageBox with the CString is commented out then it runs fine.
-Steven
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|
|
CString and CStringArray objects are different when they can be accessed by several threads simoultanously. (the former are thread safe the later not).
In MT apps you have to access CStringArray's by using syncronization objects e.g. CriticalSection's.
Example:
CCriticalSection m_Sync;
In your your cpp:
m_Sync.Lock();
m_Sync.Unlock();
Bunburry
|
|
|
|
|
Geez, I hate to be completely stupid but I have a Win32 app and I'm creating a window with some static text items. I can't remember how to set the background color on my static text to match the window background. I get a white window and text with the blue-grey background.
I tried the WM_CTLCOLORSTATIC callback and return (COLOR_WINDOW +1) but it doesn't change the text background. Do I have to resort to making my own static text class to set the background to the color I want ?
|
|
|
|
|
SetDialogBkColor(backgroundcolor,textcolor); You can use this in the application construction area and it will use these color for your entire application.
|
|
|
|
|
You can also use WM_CTLCOLORSTATIC but you need to return a handle to a brush or else it won't work. So create a brush based on the background color and then return it from WM_CTLCOLORSTATIC.
|
|
|
|
|
When I create a udp socket and then bind to port 0 and set receive timeout to 5 seconds and then call recv it the recv does not wait 5 secs but returns immediately. When I check the error code with WSAGetLastError the error code is WSAECONNRESET. Why is the connections reset ?
I am using UDP and I am not connected .
What I am doing wrong ?
Here are the steps again
1) Create a UDP
2) Bind to 0
3) Send something to a destination address
4) setsockopt SO_RCVTIMEO to 5 secs.
5) try to recv something within 5 secs. But here it returns WSAECONNRESET !!!
What is wrong ?
Orcun Colak
|
|
|
|
|
The recv function is called by TCP sockets.
When using a UDP socket, you should call the recvfrom function.
|
|
|
|
|
Hi,
I have trouble with this type, need help.
Consider this function declaration:
SCODE SetData(VARIANT FAR* pData)
What I have is a sample code which reads in data from a file and works just fine. A COleSafeArray is passed to the function as follows:
COleSafeArray osa;
SAFEARRAYBOUND sab;
sab.cElements = file.GetLength();
sab.lLbound = 0;
osa.Create(VT_UI1, 1, &sab);
void* buffer;
osa.AccessData(&buffer);
file.Read(buffer, file.GetLength());
osa.UnaccessData();
SetData(osa);
I want to pass a string to this function and can't figure it out how. Please help.
Bunburry
|
|
|
|
|
I would like to place text on a tool bar that is not associated with any button. I have seen this in other applications. Does anybody have any suggestions?
Thanks.
Eldon Zacek
Czech-Mate Enterprises, LLC
|
|
|
|
|
|
I just want to know if it's possible to place a transparent bitmap on a dialog?
Exemple: I have a bitmap of a donuts.
I want the middle of the donuts to be transparent.
So that I can see the windows background.
Is it possible to do that?
thanks!
|
|
|
|
|
I believe you'll have to load the bitmap manually, alongside with a mask, and use MaskBlt() accordingly in the WM_PAINT handler.
I don't know a way to just drop the semi-transparent bitmap onto the dialog in the resource editor...
--
Eventhough the forrest is full of trees, there's still no tree between the trees.
|
|
|
|
|
You need to either apply your own mask, or if you're using W98 and higher only, you can use TransparentBlt. Or GDI+, of course.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I'm used to developing using the VisStudio 6.0. To add a new dialog to an existing project in that IDE I mapped the WM_INITDIALOG to the OnInitDialog. If you try to go into the code and add these manually they won't work, won't display on DoModal(). It's been my experience that you have to add the dialog class using the ClassWizard in order to make the mapping work.
Ok, question...using VisStudio.NET and unmanaged C++ how do I add this same message map? Adding OnInitDialog manually produces the same results I saw in 6.0
|
|
|
|
|
Use the Properties pane/window. One of the buttons is for overrides, another is for messages.
Software Zen: delete this;
|
|
|
|
|
I'm trying to add property pages to a property sheet, and calling set wizard mode for a wizard style app. I have 2 questions, one how can i get the property page i add to fill the entire client area ( except for the area at the bottom that has the next, cancel buttons ), and how can i get the rectangle coordinates of those buttons so that i can change the dialog color to white except for where the buttons appear? I am overriding the WM_ERASEBKGND message to change the background color of the dialog area and this works fine except it applies to the area behind the buttons.
Thanks for the help
|
|
|
|
|
Inherit your own class from CPropertySheet and override its WM_ERASEBKGND message. To get the buttons from the class use the ids of IDOK, IDCANCEL, IDHELP and I think IDWIZNEXT, IDWIZPREV.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
|
I need an array of CMenu pointers, so that I can loop through the array and do stuff like:
CMenu* pFlyOutMenu = new CMenu[sizeSub];
for (int i = 0; i less than sizeSub; i++)
{
pFlyOutMenu[i]->CreatePopupMenu();
pFlyOutMenu[i]->AppendMenu etc
}
I am doing something incredibly wrong , but it says :
C:\BKView.cpp(264) : error C2819: type 'CMenu' does not have an overloaded member 'operator ->'
Appreciate your help,
ns
|
|
|
|
|
You've declared pFlyOutMenu to be an array of CMenu 's, not an array of pointers to CMenu 's, hence:
CMenu* pFlyOutMenu = new CMenu[sizeSub];
for (int i = 0; i < sizeSub; i++)
{
pFlyOutMenu[i].CreatePopupMenu();
pFlyOutMenu[i].AppendMenu
etc
}
Software Zen: delete this;
|
|
|
|
|
Yikes! Shows you how inexperienced I am.......many thanks...I see my mistake now.
Appreciate your help,
ns
|
|
|
|
|
Hi all;
I'm using the CShellList class in a project I'm working on. I need to fill up a CComboBoxEx (as well as a CListCtrl) with what is normally seen in the drop-down of a CFileDialog, i.e., My Documents, Desktop, Network Neighborhood, etc. CShellList has calls to get the correct icon depending on the file extension, and it has calls to fill up an image list with the system icons [AttachSystemImageList()], but the position of a particular icon (say, Desktop) in this image list is variable. CShellList also has a GetImageListIcon(CString) which will retrieve the correct icon when passed "C:\\My Documents\\"; but I do not know what string to pass it (if one exists) that will get me the icons for the Desktop, Network Neighborhood, etc. I need to either a.) know what strings to pass it to retrieve the correct system icon, or b.) know how to detect what a particular icon in the image list filled by AttachSystemImageList() relates to. Any help would be greatly appreciated.
Thanks,
Thomas
|
|
|
|
|
Is it possible for an exe file that is running to open the same exe file and append data to it.
Thanks
|
|
|
|
|
I don't believe that this is possible, in a simple context. Rather you have to go about and copy the executable to some new file, append the data to the new file, and then write some special keys in the registry such that the next time Windows starts up, the original file is deleted and then the copy is renamed.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.
|
|
|
|