|
Hi friends,
I'm going to compose a new bitmap by myself, and I'm using buffer to store up the data inside bitmap. But I did it wrong, and I get conflicts on that. can somebody help me and teach me how to store up correct contents in buffer??
I just want to draw a black "cross" on the center of bitmap with (1024x1024 pixel)
unsigned char *mBuffer = NULL;
int i;
int mByte = 1024/8;
int mWidth = 1024;
int mHeight = 1024;
for(i=1; i<=mHeight; i++)
{
if(i< mHeight/2)
{
memset(mBuffer+(i*(mWidth/2)), 0xff, 1);
}
else if(i==mHeight/2)
{
memset(mBuffer+(i*(mWidth)), 0xff, mByte);
}
else
{
memset(mBuffer+(i*(mWidth/2)), 0xff, 1);
}
}
forgive my stupid~, I really don't know how to store up the buffer..
thanks for help
|
|
|
|
|
Forget the buffer appoarch!
Creating for latter use:
1) Create a display compatible device context (memory DC).
2) Create a compatible bitmap of the size needed.
3) Select the bitmap into the device context.
4) Use GDI to draw the cross on the bitmap.
5) Select the previous bitmap into the device contest.
6) Delete compatible device context.
If you are keeping a copy of the bitmap for latter use, then you are all set.
In OnDraw():
1) Create compatible device context (memory DC).
2) Select bitmap into DC.
3) Blit to window.
4) Select previous bitmap into DC.
5) Delete compatible DC.
If you do not need to keep a copy of the bitmap.
In OnDraw():
1) Create a display compatible device context (memory DC).
2) Create a compatible bitmap of the size needed.
3) Select the bitmap into the device context.
4) Use GDI to draw the cross on the bitmap.
5) Blit to window.
6) Select the previous bitmap into the device contest.
7) Delete compatible device context.
INTP
|
|
|
|
|
Hi
Any one have any ideas on how to determine the size of a directory and any subsirectories?
I tried creating a console application using the _findfirst()/_findnext() functions. I think there must be an easier way.
Thanks in advance for any sugestions/comments.
|
|
|
|
|
Yes! But I would have to do the same reseach you need to. By the looks of it you may have already determine there is more than one way to do it. There are articles at codeproject and elswhere on this subject and there may be something in the FAQ. Try keywords: searching, directory, CFile, find. You also might try searching for passed questions posted, as simular questions have been asked before.
INTP
|
|
|
|
|
When I overide the CWinapp::Run, and drag the toolbar from the Mainframe window, I noticed the mainframe area where the toolbar was does not update. It leaves a blank area. Any ideas?
Thanks
|
|
|
|
|
ok i have very strange problem in first case everything is ok
<br />
int (*handler[15])(int parm); <br />
int user_trans_quit(int parm); <br />
<br />
int user_trans_quit(int parm){ <br />
printf("Just a test %d", parm); <br />
return 0; <br />
} <br />
int _tmain(int argc, _TCHAR* argv[]) <br />
{ <br />
handler[1]=user_trans_quit; <br />
handler[1](1); <br />
} <br />
but when i try to meke OO compiler give me this error "error C2064: term does not evaluate to a function taking 1 arguments"
<br />
#pragma once <br />
class PacketHandler <br />
{ <br />
private : <br />
<br />
public: <br />
PacketHandler(void); <br />
~PacketHandler(void); <br />
int LoginAck(char *parm); <br />
void Action(int i, char *data); <br />
int (PacketHandler::*handler[255])(char *parm); <br />
}; <br />
.... <br />
#include "StdAfx.h" <br />
#include ".\packethandler.h" <br />
<br />
PacketHandler::PacketHandler(void) <br />
{ <br />
handler[1]=LoginAck; <br />
} <br />
<br />
PacketHandler::~PacketHandler(void) <br />
{ <br />
} <br />
int PacketHandler::LoginAck(char *parm) <br />
{ <br />
return 0; <br />
} <br />
void PacketHandler::Action(int i, char *data) <br />
{ <br />
handler[i](data);
} <br />
10x in advance
PS:sry about my bad english
|
|
|
|
|
TRY...
define "LoginAck" as a static function
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
|
I think XSimon is correct about making LoginAck() static. You also need to forward declare your class type "class PacketHandler". Of cource I understand this is only a sample, so the lack of a contructor I am ignoring. The line "handler[1]=LoginAck;" gives the impression you are thinking that the array starts at 1, it does not, the range is 0 to 254. If you want 0 - 255 use 256 instead of 255 in your declaration.
Considering where the error occurs, you probably need to declare "int (PacketHandler::*handler[255])(char *parm);" as static.
God luck!
INTP
|
|
|
|
|
found the problem 10x alot
i must call function in this way (this->*handler[i])(data);
.. dont know way its look totaly stuped for me .. but its work
10x for the help
|
|
|
|
|
I want to make an app that write some text on the taskbar. But everytime WM_PAINT is handled I have to re paint it. My question is how I can hook the taskbar and get notified when WM_PAINT is handled.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Put the app in a DLL that also contains a basic COM object. Use the SHLoadInProc() function to cause the DLL to be loaded into explorer's address space and an instance of the COM object to be created. In the initialisation of this object, you can subclass the taskbar and handle whatever messages you need. Use spyxx to find the window structure so you can find the taskbar at runtime.
Hope this helps,
Ryan "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"
|
|
|
|
|
Ryan Binns wrote:
Hope this helps
Yeah god damnit!
I just have to learn hom to create a COM object...
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Hi,
I would like to know how I can create a shortcut of a file and put that on the desktop from my MFC sdi application?
|
|
|
|
|
Hi,
See the article how to create IShellLink in Desktop
http://www.codeproject.com/shell/desktopshortcut.asp
With Regards,
R.Selvam
|
|
|
|
|
how to modify system path?
Hi,
How can I modify the system verables (and user variable) PATH from my MFC application?
|
|
|
|
|
Hi,
I am trying to add and edit records to MS Access database from a dialog box. I created a dialog box by using AppWizard. Also, i created a derived class of CRecordset by using ClassWizard. The following is my ONOK function:
void CComplaintDlg::OnOK()
{
// CDatabase complaints;
//complaints.OpenEx("DSN=Complaints",CDatabase::noOdbcDialog);
// complaints.Open("Complaints");
// complaintRecord cr(&complaints);
complaintRecord cr;
cr.Open();
cr.MoveLast();
if(!cr.CanUpdate())
AfxMessageBox("dd");
cr.AddNew();
UpdateData();
cr.m_CallerName = m_Complaint_Name;
cr.Update();
cr.Requery();
cr. Close();
CDialog::OnOK();
}
After i compile and run it, it does not update the data file. What did i do wrong?
Thanks in advance.
csgogogo
|
|
|
|
|
Hi,
you can try the following way,
CDaoDatabase m_db ;
CDaoRecordset *m_set ;
COleVariant m_var ;
CString m_str ;
m_db.Open ( "sample.mdb" ) ;
m_set = new CDaoRecordset ( &m_db ) ;
m_set -> Open ( dbOpenDynaset, "select * from table" ) ;
m_set -> MoveFirst( ) ;
m_set -> Edit( ) ;
UpdateData( TRUE ) ;
m_set -> SetFieldValue( "complientname",( LPCSTR ) m_Complaint_Name) ;
m_set -> Update( ) ;
With Regards,
R.Selvam
|
|
|
|
|
Hello,
I have a dialog based mfc program under VBC++6.0, and I am trying to create a new dialog that pops up and displays the status of my program. In other words, I have my main dialog with a button on it, and when you push that button a loop begins. The loop makes a simple calculation and then pauses for 300ms before looping back to the beginning.
My question is: how do I make a new dialog appear on top of my main dialog so that after each calculation a string is sent to a message box telling which calculation I am on, i.e. the text box says “Working on calculation 1” and then “Working on calculation 2” and so forth.
I know how to make a new dialog appear using the CNewDialog dlg; and dlg.DoModal(); commands, and I also know how to write a single string to the text box using dlg.m_CalcNumber = "Working on calculation 1"; command. I have no idea how to overwrite this string over and over again. Please help!!!!!!!! Much thanks in advance!
~Loren
|
|
|
|
|
You need a modeless dialog, not a modal one.
Instead of calling DoModal, you need to call Create then ShowWindow.
Use the handle of the dialog and send a message whenever you need to update the text.
|
|
|
|
|
1. You need to make your 2nd dialog modeless, call Create instead of DoModal.
2. You can then perform your calculations and update the modeless dialog after each calculation.
3. You call DestroyWindow to remove the modeless dialog when complete.
You need a message pump to make your modeless dialog redraw. The could be after each calculation or embedded within to get more frequent updates.
You could add a cancel button to your modeless dialog and store a value in a bool when it is clicked. You then check the bool in the calculation to see if you want to quit.
Hope this fragment helps:
C2ndDialog dlg;
dlg.Create(IDD_2ND, this);
dlg.ShowWindow(SW_SHOW);
AfxGetMainWnd()->EnableWindow(FALSE);
{
//do calculation
//update value in dlg
MSG msg;
while ( ::PeekMessage( &msg, NULL, NULL, NULL, PM_NOREMOVE ) )
{
//message pump to redraw dlg
AfxGetApp()->PumpMessage();
}
}
while (calculating);
AfxGetMainWnd()->EnableWindow(TRUE);
workDlg.DestroyWindow();
j a m s p o o n
|
|
|
|
|
Hey Gang,
I am working on creating a custom GUI using C++ (primarily for game programming). For the most part, the GUI will mimic the structure and functionality of the Java Swing GUI 1.1.
The Swing GUI has a 'Component' class with a child 'Container' class that inherits from Component. (A Container is basically a Component that can contain multiple Components.)
The problem I am having using C++ is that the Component Class needs a function 'DeleteFromParent' that retrieves a Container object and calls one of the Container member functions.
Using a forward declaration I can retrieve a Container object in a Component function, but I still can't call any of the Container functions because the class has not yet been defined.
Any suggestions?
Thanks
Todd
|
|
|
|
|
i m doing matlab c++ programming and I met some problems which I cannot solve.
to consider
[features, targets] = improved_DA1(x, [cluster,0.95]);
in matlab....
what should i do in order to call the [cluster,0.95] in Matlab C++ ?
i did try to use mwArray(cluster , 0.95) and i get the following compiling result:
matlabwizard\matlabfunction.cpp(102) : error C2665: 'mwArray::mwArray' : none of the 21 overloads can convert parameter 1 from type 'class mwArray'
C:\foo\matlabwizard\matlabfunction.cpp(103) : error C2664: 'matlabmain' : cannot convert parameter 1 from 'class mwArray' to 'int'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
can anyone help me?
thank you very much
Matlab C++ newbie
|
|
|
|
|
Could someone tell me the realtionships between OnPaint / OnSize / OnCreate / OnInitialUpdate / OnUpdate of a view and it what process?
It seem they all get used and I cannot figure out in what sequence.
Which method should do the initial data processing - OnPaint ? MFC wizard notes " Do not use in view" , but it adds GetDocument code in OnPaint - why?
My application has several views ( graphics and data tables) of a document which initially has no data in it. I need to build all these views and than fill them up with data at random intervals. I have managed to build initial tiled views, but I am having trouble updating (UpdateAllViews) and resizing individual views. I have also noted that some of the methods are used more than once in a process - especially OnPaint. My basic test MFC MDI application seems to go thru several different sequences each time I start it.Thanks for your help. Vaclav
|
|
|
|
|
Vaclav wrote:
It seem they all get used and I cannot figure out in what sequence.
You might want to set a breakpoint at the beginning of each one to see the order in which each is called. Be careful with OnPaint() , however, as it's called a bunch!
Vaclav wrote:
Which method should do the initial data processing
How about OnInitialUpdate() ?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|