|
i'm trying to store points, and then redraw in the OnDraw function, but i'm not successful.
I've declared in the header file
typedef std::list<CPoint> CListaPuntos; inside the class there's:
CListaPuntos ListaPuntos;
In the constructor of the class, i've written:
m_PosMouse.x=-1;
m_PosMouse.y=-1;
this->ListaPuntos.push_back(m_PosMouse);
In the list, i store a Cpoint variable with (-1,-1)
Then, this is the function which draws and stores points in the list
void CVentanaPizarra::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_DibLapiz)
{
CRect rect;
GetClientRect(rect);
if ((nFlags == MK_LBUTTON) && ((m_PosMouse.x>rect.left+90) || (m_PosMouse.x==-1)))
{
CClientDC dc(this);
CPen Lapiz;
Lapiz.CreatePen (PS_SOLID,1,RGB(0,0,0));
dc.SelectObject(Lapiz);
if (point.x>rect.left+90)
{
CPoint punto;
if ((m_PosMouse.x!=-1)&&(m_PosMouse.y!=-1))
{
this->ListaPuntos.push_back(point);
dc.MoveTo(point.x, point.y);
dc.LineTo(m_PosMouse.x,m_PosMouse.y);
}
dc.MoveTo(point.x, point.y);
this->ListaPuntos.push_back(point);
punto.x=point.x+(int).5;
punto.y=point.y+(int).5;
dc.LineTo(punto.x, punto.y);
this->ListaPuntos.push_back(punto);
}
m_PosMouse=dc.GetCurrentPosition();
}
}
CDialog::OnMouseMove(nFlags, point);
}
this function compliments the abovementioned one:
void CVentanaPizarra::OnLButtonUp(UINT nFlags, CPoint point)
{
m_PosMouse.x=-1;
m_PosMouse.y=-1;
this->ListaPuntos.push_back(m_PosMouse);
CDialog::OnLButtonUp(nFlags, point);
}
and this is the onpaint function:
void CVentanaPizarra::OnPaint()
{
CPaintDC dlgDC(this);
PintarBlanco(dlgDC);
if (ListaPuntos.size()>1)
{
CPoint punto1, punto2;
for (CListaPuntos::iterator i = ListaPuntos.begin(); i != ListaPuntos.end(); i++)
{
punto1= *i;
if (i==ListaPuntos.end())
break;
if (punto1.x!=-1)
{
dlgDC.LineTo(punto1.x,punto1.x);
dlgDC.MoveTo(punto1.x,punto1.y);
}
i++;
if (i==ListaPuntos.end())
break;
punto2= *i;
if (punto1.x!=-1)
dlgDC.LineTo(punto2.x,punto2.x);
dlgDC.MoveTo(punto2.x,punto2.y);
}
}
}
something is drawn, but not what i want, or what i've drawn with the mouse.
any ideas?
thanks!
|
|
|
|
|
First of all, you are still drawing in the mousemove handler, which will not exactly make it easy for you to know what drawing works and what don't. Moreover, this code is leaking GDI-handles, as you don't unselect the pen you have created and selected. The paint handler, on the other hand, will use whatever pen happens to be selected into the CDC.
You are adding point twice to the list, which looks slightly odd. You seem to be moving to the current position, drawing backwards, and then forward again, is this really what you intended.
The OnPaint -handler is definitely odd as well - you are drawing and then moving?
I think you should get some pen and paper, and outline what you really want to do. Basically, when all prerequisits for drawing is fullfilled in OnMouseMove, just add the current point to the list. Invalidate and redraw the window as appropriate. Then, in OnPaint, create and select the pen you want to draw with. Set the initial position with MoveTo . Loop the list, and call LineTo for each point. Voilà!
|
|
|
|
|
thanks for all the tips!!
they really helped me!
|
|
|
|
|
Hi,
We are planning to send some Fax related data as a SOAP with Attachments messages to a Fax consuming Service over MQ. I would like to know if it is possible (in .NET, PocketSOAP or SOAPToolkit) to create the SOAP Message along with attachments and then serialize it to a byte stream, which can then be used to populate the MQ Message. What I am looking for is the equivivalent of the SAAJ library in Java. Can anybody point me to some info on this or give advise.
Thanks,
Kris
|
|
|
|
|
One note, AFAIK .NET uses DIME, and cannot read MIME, so you won't get 100% compatibility. I think in the future there is supposed to be a "standard" format that everyone will use. Now, if you are 100% Microsoft on all sides, this won't be a problem. And some non-Microsoft code (e.g., Apache Axis) can understand both.
Somebody correct me if I'm wrong, though.
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|
|
Thanks for your reply. Unfortunately I dont have a choice about the receiving end. It expects SOAP with MIME Attachments. I couldnt find any examples with MIME attachments and .NET. That's why I had mentioned - PocketSOAP which seems to support it but was wondering if it was tranport dependent (as I am not using HTTP but MQ). Apache also has a C++ Axis implementation. I should probably look at it too. Any other suggestions would be welcome.
|
|
|
|
|
That is what we found as well. Also we got DIME working between ASP.NET (IIS) and Tomcat. It wasn't easy but it works.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
How can i load the icon from antother application/process and set it as the icon for a MFC list control item
|
|
|
|
|
hi!
I never did THIS but... here is a code sample
how to load some ressource from a DLL
extern "C" DllExport BYTE* GetLogo(int &nSize) {
DWORD dw;
HRSRC hRes = FindResource(g_hInstance,_T("IDR_LOGO"),_T("Images"));
dw = GetLastError();
HGLOBAL hg=LoadResource(g_hInstance,hRes);
LPVOID lpRes=LockResource(hg);
nSize = SizeofResource(g_hInstance,hRes);
dw = GetLastError();
return (BYTE*)lpRes;
}
I think you have just to get the HINSTACE to the app you want, and then load the ICON from it!
good luck!
|
|
|
|
|
dear fellow i making final project of video compression mpeg to mp3.... i also need to build media player and codec for it....
i need help for codec because in MFC i don,t hv any idea about codec kindly help me
if any body could help kindly mail me at moeen_ud_din@hotmail.com or leave a messsage here thanks
|
|
|
|
|
The DirectX SDK (DirectShow) is one of the best starting points for writing codecs. You can download it from microsoft.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
I have a project that will use a tabbed control (property pages?) as the primary interface. The tabs are arranged in such a way as to guide the user in the proper order of steps. Anyway, given that I need a title bar, a menu bar and possibly a toolbar - and eventually the whole thing needs to be sizeable, which is the best interface to use: MDI, SDI, or Dialog based?
I've done a lot of C++ coding, but have very little experience in "starting from scratch" - so I plan to use the wizard in Microsoft's Visual C++ to get me started.
Any suggestions, pointers to articles, etc. would be greatly appreciated.
Thanks!!
|
|
|
|
|
Do you need multiple document support? If not, then you can rule that app structure out. From what you have been saying, a SDI style app with a CFormView view class. That would probably be your easiest straightforward path to take.
Keep in mind that you could use a CDialog-based application structure. Toolbar(s) can be added to a dialog and of course a menubar. There are articles on this site of how to add a toolbar to a dialog. Skim the articles on this page for help on adding resizability and toolbars to a dialog: http://www.codeproject.com/dialog/[^]
I hope this helps. Good luck in your programming efforts!
Happy Programming and God Bless!
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
Thanks, bneacetp. I've been doing some more study since my post, and at this point I think I'm leaning toward the learning curve of the SDI style - since I'll eventually need most of what it does (including printing from the app, resizing, etc)
Thanks, also, for the well wishes!
Happy Programming and God Bless to you, as well!
-The Pilgrim
"There are no absolutes" is an absolutley illogical statement...
|
|
|
|
|
I have a MFC Dialog which contains a Bitmap. When the application is run the dialog is always on top and I cant have any other Windows placed over it.
I have looked at the Dialog settings and cant find any that would cause this effect (problem).
Have I overlooked anything as I want to place the dialog in the background when required.
grahamfff
|
|
|
|
|
|
I have a "Generic CWnd" class named CData. This class will hold all of my data for the program. The "instance" is created in the CMainFrame constructor. Serveral dialog classes are created and launched fron the CData class. However, I cannot get the data from those dialogs realized or recognized by CMainFrame::m_CData(my instance of CData class in CMainFrame). The dialogs are created "modeless" in CData; and while active CData gains the data; but when returned to CMainFrame the data is not there in CData.
Any ideas?
LAM
Programming! - Isn't it Great!
See you in CyberSpace!
|
|
|
|
|
Sorry if sounds patronising
have made the CDialog objects or the getter methods public in the CData class?
If you clarify what your are trying do.
|
|
|
|
|
what is Wrong in my Code Follow .Why Add Text not display in Listview Control Write by C API
#include <windows.h>
#include "stdafx.h"
#include <commctrl.h>
#include "resource.h"
#include <stdio.h>
HINSTANCE G_hInst;
HWND G_hwnd;
HWND hComBox;
BOOL Init_Listview(HWND );
int Add_Item(HWND hwndListView,LPTSTR textItem);
void Add_SubItem(HWND hwndListView,LPTSTR textSubItem,int col);
BOOL CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
G_hInst=hInstance;
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwICC = ICC_LISTVIEW_CLASSES;
InitCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
BOOL bRet = InitCommonControlsEx(&InitCtrls);
DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, (DLGPROC)DialogProc,0);
return 0;
}
BOOL Init_Listview(HWND hwndListView)
{
//SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT );
HIMAGELIST himlSmall;
HIMAGELIST himlLarge;
LPTSTR lpszCols[] = {TEXT("Column Name"),TEXT("Data type"),TEXT("Length"),TEXT("Allows Nulls"),0};
LVCOLUMN lvColumn;
//initialize the columns
lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM|LVS_EDITLABELS;
lvColumn.fmt = LVCFMT_LEFT;
lvColumn.cx = 100;
for(int x = 0; lpszCols[x]!=NULL; x++)
{
//make the secondary columns smaller
if(x)
lvColumn.cx = 100;
lvColumn.pszText = lpszCols[x];
//InsertColumn(x,&lvColumn);
ListView_InsertColumn (hwndListView, x, &lvColumn);
}
himlSmall = ImageList_Create(16, 16, ILC_COLORDDB | ILC_MASK, 1, 0);
himlLarge = ImageList_Create(32, 32, ILC_COLORDDB | ILC_MASK, 1, 0);
if (himlSmall && himlLarge)
{
/*
HICON hIcon;
//set up the small image list
hIcon = LoadImage(g_hInst, MAKEINTRESOURCE(IDI_DISK), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ImageList_AddIcon(himlSmall, hIcon);
//set up the large image list
hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_DISK));
ImageList_AddIcon(himlLarge, hIcon);*/
ListView_SetImageList(hwndListView, himlSmall, LVSIL_SMALL);
ListView_SetImageList(hwndListView, himlLarge, LVSIL_NORMAL);
}
return TRUE;
}
/////////////////
int Add_Item(HWND hwndListView,LPTSTR textItem)
{
LVITEM lvItem;
int iItem=SendMessage(hwndListView,LVM_GETITEMCOUNT,0,0);
memset(&lvItem,0,sizeof(lvItem));
lvItem.mask = LVIF_TEXT|LVIF_DI_SETITEM|LVIF_STATE;
lvItem.iItem = iItem;
lvItem.iSubItem =0;
lvItem.pszText = textItem;
return ListView_InsertItem(hwndListView,&lvItem);
}
////////////////////////////////////
void Add_SubItem(HWND hwndListView,LPTSTR textSubItem,int col)
{
int row=0;
LVITEM lvItem;
row = SendMessage(hwndListView,LVM_GETITEMCOUNT,0,0);
row=row-1;
lvItem.mask = LVIF_TEXT|LVIF_DI_SETITEM|LVIF_STATE;
lvItem.iItem = row;
lvItem.iSubItem = col;
lvItem.pszText = textSubItem;
SendMessage(hwndListView,LVM_SETITEM,0,(LPARAM)&lvItem);
}
//////////////////////////////////////////////
BOOL CALLBACK DialogProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
{
int iSelect=0;
HWND hList=NULL;
switch(Message)
{
case WM_INITDIALOG:
{
InitCommonControls();
// OleInitialize();
hList = GetDlgItem(hDlg,IDC_LIST);
DWORD dwExStyle = LVS_EX_FULLROWSELECT|
LVS_EDITLABELS|LVS_EX_GRIDLINES |LVS_EX_HEADERDRAGDROP|LVS_EX_CHECKBOXES|LVS_OWNERDRAWFIXED ;
Init_Listview(hList);
ListView_SetExtendedListViewStyle(hList,dwExStyle);
//Add_Item(hList,TEXT("hang 1"));
}
break;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case ID_BTN_DELETE:
EndDialog(hDlg,0);
break;
case ID_BTNADDITEM:
Add_Item(hList,TEXT("Add Item text"));
break;
case ID_BTNADDSUBITEM:
{
Add_SubItem(hList,TEXT("Add Sub Item"),1);
Add_SubItem(hList,TEXT("Add Sub Item"),2);
Add_SubItem(hList,TEXT("Add Sub Item"),3);
Add_SubItem(hList,TEXT("Add Sub Item"),4);
}
break;
}
break;
}
break;
case WM_NOTIFY:
{
switch(LOWORD(wParam))
{
case IDC_LIST:
if(((LPNMHDR)lParam)->code == NM_CLICK)
{
// do some stuff here
iSelect = SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED); // return item selected
ListView_SetBkColor(hList, RGB(0,255,0));
}
if (((LPNMHDR)lParam)->code == NM_HOVER)
{
// xuli chuout lan o day
ListView_SetBkColor(hList, RGB(0,255,0)); // blue component of color
}
if (((LPNMHDR)lParam)->code==NM_SETFOCUS)
{
}
}
break;
}
break;
case WM_CLOSE:
{
EndDialog(hDlg,0);
return 0; // kill dialog
}
break;
}
return FALSE;
}
Doan code above Not display Text of Item and text SubItem
When Click Mouse on button AddItem or Button Add subItem
who discover Problem Please Show me.
Huynh van sen
|
|
|
|
|
Check out http://www.codeproject.com/listctrl/listview.asp for a good intro to Listviews under Win32 API using C.
|
|
|
|
|
how to get hash from BYTE *pass to HCRYPTHASH hHash using
CryptCreateHash and CryptHashData
//in this program hash doesn't change =(
HCRYPTPROV hCryptProv;
CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0);
HCRYPTHASH hHash;
CryptCreateHash(hCryptProv,CALG_MD5, 0, 0, &hHash);
CryptHashData(hHash,pass,strlen(fPass)+1,0);
|
|
|
|
|
You're just missing the final step.
1. Get a CSP handle - CryptAcquireContext()
2. Create a hash object and specify hash algorithm - CryptCreateHash()
3. Add data to hash - CryptHashData() or CryptHashSessionKey()
4. Keep doing 3 until added all data
5. Finish hash and get result :
::CryptGetHashParam(hnd, HP_HASHVAL, BUFF, &BUFFLEN, 0); // BUFF is hash value
or,
::CryptSignHash(hnd, T, NULL, F, BUFF, &BUFFLEN); // BUFF is result signature
or,
::CryptVerifySignature(hnd, BUFF, BUFFLEN, pub, NULL, F); // BUFF is signature to verify
Each of these functions will finish the hash (i.e. add any algorithm required padding), meaning that any subsequent calls to CryptHashData() or CryptHashSessionKey() will fail. However, you can call any of these 3 multiple times safely, the hash is only 'finished' (padded) once.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Does anybody know how to draw the background for toolbars and rebars so that they match the currently selected XP colour scheme (blue, olive or silver). Th latest version of Office implements this so I assume it is possible to retrieve the background details via some API. The visual styles help in MSDN is very brief so any help you can give will be appreciated.
Steve.
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
|
Actually, I don't think Office uses a 'public' API for this. If you run Office 2003 on Win2K you still get the same visual effects, even though Win2K doesn't support those effects itself.
Software Zen: delete this;
|
|
|
|
|