|
Thanks very much
|
|
|
|
|
I wanted to fill a rectangle with a bitmap pattern. I would like to have a sample code for doing this.
Raj
|
|
|
|
|
In GDI+ it's a snap. For GDI, it's a little harder, but not much.
If your bitmap is 8 x 8 ( yeah, right ) then you can use a brush that holds it, but I've never used it and so the name escapes me.
CDC bmpDC;
bmpDC.CreateCompatibleDC(NULL);
CBitmap bmp;
bmp.LoadImage(IDB_BITMAP);
CBitmap * pOld = bmpDC.SelectObject(&bmp);
Now just do a stretchblt across from this DC to the rect you want to fill. If you want to tile, it's a little harder - you need to either create an intermeediate tiled bitmap or do the tiled drawing to make sure you don't go too wide or high. If you go too far in a bitmap that is the right size being prepared, GDI will just ignore the bits over the edges.
Here is a code snippet from my tiling method. The pDib is a paintlib DIBSection, so the moethods won't work with a CBitmap, but it will give you the idea.
case TRANSP_BMP_TILE:
{
for (int x = 0; x < pDib->GetWidth(); x += m_TranspBitmap.GetWidth())
for (int y = 0; y < pDib->GetHeight(); y+= m_TranspBitmap.GetHeight())
m_TranspBitmap.Draw(dc.m_hDC, x, y);
}
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I am having difficulty if i need to insert an image, text and button in a cell. Some of the cells in the column do not have buttons, but some do. This means that the indent/margin set in a button cell means that the images (aligned left) do not align, has anyone any ideas as to how to modify the code, set a default margin etc.?
Cheers, Bill
image text nobutton
image text nobutton
image text button
image text nobutton
image text button
see what i mean?
|
|
|
|
|
sorry, fixed it with setmargin()
Remember, Be excellent to each other
|
|
|
|
|
Hi y'all,
moving up in software development, I thought it was a good idea to dive into extention DLL's. I've developed a suite of database-access classes which has grown up to 30 files, so I thought it would be nice to pack all these in a .lib and .dll file so distribution would be easier.
One of the features of the classes is creating a taskbaricon (which is a Dundas component, derived from CWnd). But ever since I put my classes inside an MFC extention DLL, the creation of the taskbaricon fails. This is the reason why:
* First a window is created with CreateEx(0, AfxRegisterWndClass(CS_CLASSDC | CS_GLOBALCLASS), NULL, 0, 0, 0, 0, 0, NULL, NULL) However, AfxRegisterWndClass calls AfxGetInstanceHandle and returns a NULL-value or something. Even though MSDN says that AfxGetInstanceHandle should return the handle of the dll in this case...
* After the window creation an icon has to be extracted from the resource (which I also put inside dll). But as soon as the icon is created using ::LoadIcon(AfxFindResourceHandle(MAKEINTRESOURCE(nIDResource), RT_GROUP_ICON), MAKEINTRESOURCE(nIDResource)), things go wrong again. AfxFindResourceHandle calls AfxGetResourceHandle which also returns a NULL- or corrupt handle.
So, my question is:
How can I get the AfxGetInstanceHandle and AfxGetResourceHandle working well within my .dll??
Structured programming vs. chaotic mind boggling
|
|
|
|
|
Hello
I need to access a member-function of my MFC-app via the _beginthread-function.
_beginthread(pingthread,0,(void *) (szBuffer));
"pingthread" is
void CMyAppDlg::pingthread(void* parameter)
{ ... }
But _beginthread does not seem to accept MFC-member-functions.
Any solution?
thanks
|
|
|
|
|
pingthread has to be a static member function
|
|
|
|
|
I would suggest you to read one of newcomer's articales: http://www.pgh.net/~newcomer/callbacks.htm
Lirong
|
|
|
|
|
I'd do the following:
1) Create a global function :
void ThePingThread(void * pDlg)
{
if (pDlg != NULL)
{
( (CMyAppDlg *) pDlg)->PingThread() );
}
}
2) ...calling the pingthread function in your thread
void CMyAppDlg::pingthread()
{
pParameter = m_pParamter;
// Do your pinging stuff!
}
3) Start the trhead as follows:
void CMyAppDlg::RunPingThread(void* pParameter)
{
m_pParameter = pParameter;
_beginthread(ThePingThread, 0, this);
}
It works for me!
Structured programming vs. chaotic mind boggling
|
|
|
|
|
When I try to compile the compiler reports an error in line:
( ((CServerListDlg*) pDlg )->pingthread() );
(translated from german )
"pingthread" : No access to protected element, which has been declared in class "CServerListDlg"
|
|
|
|
|
That's quite logical, because you have to make the pingThread function public.
If it's protected, it's quite impossible for a global function to access it...
Tell me if it worked for you!
Structured programming vs. chaotic mind boggling
|
|
|
|
|
hi
I have a projecy in SDI and i want to tern it to an MDI
how do i do it ???
|
|
|
|
|
TO turn it into MDI is not impossible, but certainly interesting. Make an SDI and a MDI project in the class wizard and run a comparison program on them. There is an extra class in your MDI app for starters. Figure out the differences and apply. Repeat as necessary
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I have a backgound with borland products, VB, Delphi, Java, HTML etc., but I have a rush project to be done in VC++ running in windows 98, that has to run in the background, ie, no screen, and esp. nothing in the botton toolbar. I haven't done anything that runs like this since the days of yore, under DOS, before windows.
All the searches I do finds things like how to change window and dialog backgrounds, or give backgrounds about some person or development.
I need a solution ASAP, and perhaps one of you can help.
|
|
|
|
|
Does this help?
http://www.codeproject.com/shell/systemtray.asp
|
|
|
|
|
Sounds like you need a service app. The ATL app wizard can create a service framework for you. I think there might be some service related articles on CodeProject. http://www.codeproject.com/system/cntservice.asp might be helpful. Although NT based, services can run on 9x clients.
Hope this is of some use,
Michael
|
|
|
|
|
Please help!!
I have been trying to implement a linked list class, and im having a few problems getting my head
around what it needs to do. Here I have the class, I wanted to be able to get at the first and
last elements, and be able to add things to the list.
struct node {
int data;
node* next;
};
class CLinkedList
{
protected:
int returnFirstElement(); // Return first element
int popFirstElement(); // Return and delete first element
int returnLastElement(); // Return last element
int popLastElement(); // Return and delete last element
void addToEnd(int element); // Add an element to end of linked list
void addOrdered(int element); // Adds to correct location in an orderered list
node* nextPtr; // Points to next node
public:
CLinkedList();
virtual ~CLinkedList();
};
And here is the implementation file. Basically Im having problems thinking what these
functions should do, In particular, what should the constructor do in terms of creating a new
node?
//////////////////////////////////
// Member functions....
void CLinkedList::addOrdered(int element) {
}
void CLinkedList::addToEnd(int element) {
}
int CLinkedList::popFirstElement() {
return 0;
}
int CLinkedList::returnFirstElement() {
return 0;
}
int CLinkedList::popLastElement() {
return 0;
}
int CLinkedList::returnLastElement() {
return 0;
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
CLinkedList::CLinkedList()
{
}
CLinkedList::~CLinkedList()
{
}
The thing I would usually do in a situation liek this is: node2.next = &node3
but how can you do this as node3 isnt actually created yet - see what I mean?!
Any pseudocode or advice appreciated.
Cheers
Ben
|
|
|
|
|
HOPE This Helps
In a linked list you will only go one way. unless you implement a doubly liked list, keep track of the head pointer.
The first item, or head, is accessed from a fixed location, called a "head pointer."
if that head pointer does not exist you then need to create it and populate and keep track of it.
and set the next to NULL, each time you add new node you set it to the next and det the next of it to null.
You must alway keep track of the head pointer. and work with a worked node.
hope that helped in clearing things a bit.
Cheers
Alfadhly
It is Illogical to define an inventor by his invention
|
|
|
|
|
A linked list can be singly or doubly linked, as the other reply said. You can do it two ways - first make the end nodes of a different class or ( my preference ) simply make the pointers NULL if you are at an end ( i.e. the last one has NULL for the next item, the first NULL for previous if doubly linked ).
I absolutely appluad you for writing your own linked list, but unless it does something special that a normal one doesn't do, I'd recommend using the STL for your container classes. You get to write code that will compile anywhere, lots of algorithms for free, etc. Write your own for sure, so you know how it all works, but then use the standrd one.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Does anyone knows or have an idea of how long does it take to do a full compilation of the Windows NT operating system. No, I DO NOT have the source code for the OS but would like to use the information as reference in a document on source code organization I am putting together at work.
Thanks in advance.
|
|
|
|
|
Hi ,
I have ATL Component with it's interface exposing a method which will pass the Disconnected Recordset pointer.
At the client side,I can get this Recordset pointer.But, I could not access this Recordset Pointer as it gives error that
"The operation requested by the application is not allowed if the object is closed ".I should not create another Recordset pointer on the client side.How can I rectify the problem ?
Thanx in advance for the help.
Regards,
yamini.
|
|
|
|
|
Did you AddRef the recordset pointer before you returned it?
Phil Boyd
MCP
"I took the road less traveled..."
|
|
|
|
|
Hi,
I tried to AddRef the Recordset pointer before returning . But, it did not work.
The function prototype at Server .
HRESULT GetAllElements([out,retval]_Recordset **ppRecordset);
The code at the client goes this way.
void main()
{
//Creating an instance of the Component and getting the Interface say Idemo
_Recordset *ppRecordset;
Idemo->GetAllElements(&ppRecordset);
if(SUCCEEDED(hr))
{
ppRecordset->MoveFirst //Here I am getting the Error that if object is closed can't do the operation requested by the Application.
}
}
I must not create another Recordset at the Client side .
Thanx in advance for the help.
Regards,
yamini.
|
|
|
|
|
Hi,
Sorry if this is the wrong place to ask, but how do you get an outline for say a solid filled box; the only way i could think of is to render the filled box first, then render the outline.. anyone know a better way??
Cheers
|
|
|
|