|
Next, read about SQL injection[^] to understand why code like that is dangerous.
|
|
|
|
|
You should avoid this coding style as it may lead to some serious problems. Google SQL Injection, you yourself will understand.
|
|
|
|
|
I need an existing linkable chat control for client/server communication, which is readonly and text-only.
When users say something, chat contents are added to the control.
Texts displayed on the control have multiple types of links, such as user-name, comments, advertisements and something else. If clicking on those links, related events or messages are submitted to the control's parent or itself, so that I can show further info by types of those links, i.e. show pop-up menu or show some windows.
Thanks
BTW: or any idea to develop the control easily?
|
|
|
|
|
|
Hi, dear all,
I am creating a MFC DLL utility program that will be used by client application through exported functions in DLL.
Now I have to problem about how to create a modeless dialog in MFC dll. I searched some examples about creating modeless dialog in MFC exe application. Usually they create a dialog pointer in View class and initialize it as:
m_pDlg = new CMymfc9Dialog(this);
But my program is MFC DLL, there is no CView class, how can I initialize the m_pDlg? what argument should I pass to it?
Thanks!
|
|
|
|
|
You can simply pass NULL to CDialog constructor as parent window. In this case, MFC searches a proper one. If it doesn't find any, dialog's parent window is set to the main application window.
You also don't have to use above constructor for modeless dialog boxes. You can use default constructor then you can specify parent window later by Create() function.
m_pDlg = new CMymfc9Dialog();
m_pDlg->Create(IDD_MYMFC9DIALOG, NULL);
m_pDlg->ShowWindow(SW_SHOW);
|
|
|
|
|
Thanks!
Now I use pMatTable = new CMatTable(this->m_pMainWnd); pass main window as parent window, it works now.
|
|
|
|
|
In your DLL, put this function:
void MyDLLClass::ShowDialog(CWnd *pWnd)
{
m_pDlg = new CMymfc9Dialog(pWnd);
} In your app, call the ShowDialog() function.
|
|
|
|
|
|
Hi,
From your posting, I think that you wanted to a dialog box which is added a resource in your MFC dll. If I am right, It is a matter of simple. Please see the sample below.
extern "C" __declspec(dllexport) showMyDialog(CWnd *parent)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
CDialog *myDialog = new CDialog(IDD_DIALOG1, parent);
myDialog->ShowWindow(SW_NORMAL);
}
Make sure that you release the allocated memory in WM_NCDESTROY message handler code.
Then about the code. There is a problem when we want to show a dialog from an MFC DLL. The MFC will using main application resource handle to find the specified resource. If you not specify the AFX_MANAGE_STATE(AfxGetStaticModuleState( )); at the begginig of the exported function, the MFC framework will try to find the resource in main application's resource. If the specified resource not found, then the showWindow fails and if found, MFC will try to load that resource may causing an unexpected behaviour. For more infomation see the MSDN documentation of AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
Hope this helps
Thanks
Nitheesh George
Nitheesh George
http://www.simpletools.co.in
|
|
|
|
|
Thanks for reminding me, I do get application crash since I didn't use AFX_MANAGE_STATE(AfxGetStaticModuleState()) at first.
|
|
|
|
|
Hello everyone
I have a graduation project and
I need to know how to convert an image (black & white) to a file (zero & one) in the VC++
and OpenCv ?
Or in other words how can Read image as a File ??
Can anyone help me :/
|
|
|
|
|
You really need to give more input than that. What is the format of your 'image'? Is that a HBITMAP, or some other data structure? What format should the output file have? Raw/jpg/bmp/gif?
Shatha88 wrote: Can anyone help me :/
Probably not, as it is right now.
|
|
|
|
|
Well
I want to convert the (JPG )image to (0`s & 1`s)text file and
I used this code from internet and gave me this file, but not 0 and 1 also does not draw my picture
#include<iostream>
using namespace std;
#include<stdio.h>
#include<fstream>
#include <cv.h>
#include <highgui.h>
int WritePixelsToFile(IplImage *img,const char *filename)
{
ofstream file;
file.open (filename, ios::out);
if(file==NULL)
{
perror("Unable to open specified file");
return -1;
}
int i,j;
CvScalar s;
CvSize size=cvGetSize(img);
for(i=0;i< size.height;i++)
{
for(j=0;j< size.width;j++)
{
s=cvGet2D(img,i,j);
file << s.val[0];
}
file <<"\n";
}
file.close();
return 1;
}
int main ()
{
char name []= "C:\\file1.txt";
IplImage *imgI = cvLoadImage("C:\\org.jpg");
IplImage *dst = cvCreateImage( cvSize( 30, 30 ), IPL_DEPTH_8U, 1 );
cvCvtColor( imgI, dst, CV_RGB2GRAY );
IplImage *binary= cvCreateImage( cvSize( 30, 30 ), IPL_DEPTH_8U, 1 );
cvThreshold(dst, binary, 150, 255, CV_THRESH_BINARY);
cvSaveImage("C:\\ooo.jpg",binary);
WritePixelsToFile(binary,name );
return 0;
}
the output will be
"
255252253245254252254255241248255255255255255254255249255252255231254255246246255248254255
25323024725523525525522725524921014791656572100127220253217255230252255243242251253232
25524425525124725124925516365042480701035151232251254237255255244255243
25225524423825524321369067000451410200033186251247253255247254255
2532382452532322065221326102167185181182169831667141146255253226255237255
24825525524621000110121233255244249255247246255254142230016126255235249252243
2552552522191653325233244255255255254252252241255250236222681030187254243255251
25524425452218292482422542532402392552552542552462472522552307341217232255240252
24625515831102212532552552552552552552552552482552322552552532204420124245254255
255242553214023825025525525525525525525525524525524225525425325516241039224243255
2502000132624025025525525525525525525525525525425224725524924525524863210169246254
2431406129525525325425525525525525525525525525524924625025424824325515121086255255
2558214016925525524225525525525525525525525525424825024825525524125421001628255255
2555210019625025425525525525525525525525525524825425525025325524625424415023248248
2504710419824625125525525525525525525525525525225525525324824625325225526025239248
2554954208255251244255255255255255255255255255253244255255253255253254008237255
255649251762532552412502552482422522552552552532422552482512552442552170831255255
242113501372522422552542532552552552472472552532482552472402532542491815962255255
255186022422392552472522412422472472522552492492552522552552472442537290142254250
23825314143162249244255255255251246255255236249255252255244250255196150219249245
25123211850492322552342452552552492512542492532442522492182552437412071242255255
2442552081517383254255250236241254248245255251254244255255227119501196245255248
2522492391462100116235255254242255255239252250255245244239125252107255254249238
25524825525510225005719525524025025524825525523425520078140468255238255237249
2542332402552151082301138216823324725524122718795103471252252254255255255
2362552552372552551582503240227484170110141086252252253254255255255
255255253249252251234212107160717061702111059189248255252253254255255255
2462502522512522552552552532191515517180650141223255255244240253253254255255255
238254255251253255253232238230241255255245247255255242240253255255255251253254255255255254
255253255255240225239255255255239248250255252255253247249255251226238247254254255255255254
"
and my picture is image : Black circle ,size = 30 × 30 pixels
can you help me
|
|
|
|
|
Shatha88 wrote: to a file (zero & one)
How do you think your image is stored on the hard disk ? You really think that on your hard disk there's a small image drawn there somewhere ?
Your image is stored as any other file: a bunch of bits.
Could you please elaborate your question ?
|
|
|
|
|
If I have in header file the follow code :
private:
typedef struct ItemData
{
BOOL bState;
LPCTSTR lpszString;
DWORD dwItemData;
ItemData(LPCTSTR lpszString,BOOL bState,DWORD dwItemData);
virtual ~ItemData();
};
and in cpp file I try to use it :
ItemData* pData = new ItemData(lpszString,TRUE,-1);
I get the follow link error :
error LNK2001: unresolved external symbol "public: __thiscall CComboBoxExt::ItemData::ItemData(char const *,int,unsigned long)" (??0ItemData@CComboBoxExt@@QAE@PBDHK@Z)
What I'm doing wrong ?
|
|
|
|
|
You've forgotten to implement functions.
typedef struct ItemData
{
BOOL bState;
LPCTSTR lpszString;
DWORD dwItemData;
ItemData(LPCTSTR lpsz, BOOL bSt, DWORD dw)
: lpszString(lpsz), bState(bSt), dwItemData(dw)
{
}
virtual ~ItemData() { };
};
|
|
|
|
|
You are perfectly right ! Thank you !
|
|
|
|
|
Besides, two things:
1. You forgot to provide the typename for your typedef. Eithr delete that typedef keyword or provide the name after the definition of the struct.
2. Do you intend to add types that are derived from ItemData? If not I advise you to remove the virtual destructor! It will only add to the size of the objects because it has to add a hidden pointer to the virtual function table. Virtual destructors are only neccessary to make sure objects are destroyed properly even when the destructor is called through the interface of a base class. But when you have no inheritance it just adds weight unneccessarily.
|
|
|
|
|
hello guys... Im using waveOutOpen function to play a voice on my Landline number. Now when I play voice in windows media player it plays fine but when I play voice using waveOutOpen() it plays low (actually you"ll have with all attention and no noise around). Wjhat can be the reason. I am using following properties for format for waveInOpen() and waveOutOpen().
WAVEFORMATEX _oFormat;
LPWAVEFORMATEX _pFormat = NULL;
_pFormat = &_oFormat;
_pFormat->wFormatTag = WAVE_FORMAT_PCM;
_pFormat->cbSize = 0;
_pFormat->nChannels = 1;
_pFormat->nBlockAlign = 1;
_pFormat->wBitsPerSample = 8;
_pFormat->nSamplesPerSec = 8000;
_pFormat->nAvgBytesPerSec = 8000;
|
|
|
|
|
Did you check the return value of waveOutOpen is MMSYSERR_NOERROR or not?
--
"Programming is an art that fights back!"
|
|
|
|
|
i am trying to make the folder invisible from the user is there any class id which make the folder invisible please help out of this
thanking you....
|
|
|
|
|
You can use SetFileAttributes()[^] to make a folder hidden.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi, I want to know how this OpenPrinter() API works.
It is returning ERROR_INVALID_PRINTER_NAME if i use this api.
On what basis it is able to tell whether printer name is valid or invalid?
Which registry key it is comparing with?
Thanks in advance.
Regards
msr
|
|
|
|
|
See here[^] for specific details of the name format. You may want to check what parameters you are using in your call.
I must get a clever new signature for 2011.
|
|
|
|