|
hello guys... I am trying to add the couple of property pages to property sheet. If I ignore all the assertions then the EXE runs properly. But if I go to the assertion it takes me to the following address
- <pre lang="c++"><b>atlmfc\include\afxwin1.inl</b></pre>
and the line
- <pre lang="c++"><b>{ ASSERT(afxCurrentResourceHandle != NULL);</b></pre>
I tried to trace the starting point and put a break point on CMyApp::InitInstance(). But the assertion is shown even before this function is called.
Again, the project builds successfuly and if I ignore all the assertions then the EXE works fine as well. What can be the problem
|
|
|
|
|
You should find in the call stack window of Visual Studio what is the origin of the problem.
Veni, vidi, vici.
|
|
|
|
|
CPallini wrote: You should find in the call stack window
Yes. The origin is the global variable for one of the PropertyPage that I have declared, in order to excess it in other TABS. It is fine because before declaring these global variables, this program was working absolutely fine with no assertions.
The constructor of the property page looks like.
CEmployementDlg::CEmployementDlg(CWnd* pParent )
: CPropertyPage(CEmployementDlg::IDD)
{
}
I dont know what resource I am missing here.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
|
Another thing to look into a global variable you have mentioned. Could you give more details about it? Like type and where it is declared?
JohnCz
|
|
|
|
|
Hi,
I am having a problem. I have a project "MicroSIP" which is used for SIP based call voice over IP. I am running it into VS 2010 and I need to customize it according to my need. For this as soon as I edit the main dialog ( Dialer ) and add some other controls ( like edit control of CEdit) and add member variable for from wizard of "Add Variable", it shows the message "unable to update DoDataExchange method".
More over if getting reference of newly placed "Edit Control" in the program , it has NULL pointer or undefined reference.
Anybody having any idea about this to resolve or some way around to resolve the issue. I am having extremely trouble for solving this scanario.
Regards
Usman Khalil
|
|
|
|
|
Sometimes the wizards get out of whack is some of the commented text that is in the header/source files is removed. Why not add the control by hand? It's really not that difficult.
This is the problem with people using wizards... when they fail, you're left with no recourse. If you learn what it is the wizard does, then you don't have to depend on it.
|
|
|
|
|
Unfortunately adding it by hand also didn't work at all.
See the problem:
It crashes now inside DDX_Control(pDX, IDC_EDIT_Address, MacAddressEditCtrl ); where IDC_EDIT_Address is the id and MAcAddressEditctrl is CWnd object.
oid AFXAPI DDX_Control(CDataExchange* pDX, int nIDC, CWnd& rControl) { if ((rControl.m_hWnd == NULL) && (rControl.GetControlUnknown() == NULL)) // not subclassed yet { ASSERT(!pDX->m_bSaveAndValidate);
pDX->PrepareCtrl(nIDC); ////it crashes here...and inside it int the long run inside of code somehere..it calls GetOleControlSite() and there it is observed that m_pCtrlCont is NULL.
HWND hWndCtrl;
pDX->m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl);
if ((hWndCtrl != NULL) && !rControl.SubclassWindow(hWndCtrl))
{
ASSERT(FALSE); // possibly trying to subclass twice?
AfxThrowNotSupportedException();
}
ifndef _AFX_NO_OCC_SUPPORT
else
{
if (hWndCtrl == NULL)
{
if (pDX->m_pDlgWnd->GetOleControlSite(nIDC) != NULL)
{
rControl.AttachControlSite(pDX->m_pDlgWnd, nIDC);
}
}
else
{
// If the control has reparented itself (e.g., invisible control),
// make sure that the CWnd gets properly wired to its control site.
if (pDX->m_pDlgWnd->m_hWnd != ::GetParent(rControl.m_hWnd))
rControl.AttachControlSite(pDX->m_pDlgWnd);
}
}
endif //!_AFX_NO_OCC_SUPPORT
}
}
|
|
|
|
|
Where's the code where you describe MacAddressEditCtrl? Are you positive IDC_EDIT_Address exists in the resources? When you try to access this variable, are you sure there's an instance of the dialog created? Has OnInitDialog() been called already?
If I had to guess, you're probably trying to use the control before it has been created.
|
|
|
|
|
Thanks Albert.
As you pointed out and I realized that I placed and written the code of another OnInitDialog..
It was main dialog's control of whole I was trying to manipulate of another dialog's code.
Thanks
|
|
|
|
|
Could you upload the header and cpp file of dialog class ?
|
|
|
|
|
It seems that, among the very many properties that a file can have, is a text caption, to say what is in the file. (If it is a graphic file, it would say what the image is a picture of.) Please what are the Visual C++ functions to set and read these captions for any given file?
|
|
|
|
|
Quote: If it is a graphic file, it would say what the image is a picture of
This is better called as 'preview' and can be retrieved as file buffer (which holds either jpeg/png/bmp image type) and can be parsed accordingly.
Now like the same way, you should know what other types have as text caption to extract and parse them. Isn't it?
I guess, there is no such set of methods in VC++ to do task in a generic way.
|
|
|
|
|
Sorry: I did not mean a preview image. I thought that, if I (say) photographed a diver in a hardhat diving suit, that it might be possible (after I moved the image onto my computer), to attach to the image a text comment that said "Hardhat diver, Albert Dock, Liverpool", and later to retrieve the comment knowing the filename, both within a Visual C++ for Windows program.
|
|
|
|
|
|
What I meant is: after the usual #include's:-
#include "targetver.h"
pragma once
#pragma comment(lib, "GdiPlus")
#include "targetver.h"
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows
// Windows Header Files:
#include [windows.h]
#include [gdiplus.h]
#include [stdlib.h]
#include [malloc.h]
#include [memory.h]
#include [tchar.h]
#include [direct.h]
#include [stdio.h]
#include [errno.h]
/* the square brackets should be angle brackets */
FILE *F;
if I could wrote something like
setfilecaption(F,"Hardhat diver in Albert Dock, Liverpool");
getfilecaption(F,s,n); /* get file F's caption into string s, allow n bytes for it. */
modified 15-Apr-12 15:29pm.
|
|
|
|
|
Yes indeed, I already understood that. Nonetheless, thanks for taking for the effort to ensure you'd been clear.
Edit: Think your keyboard is on the blink - you've got [] where there should be <>, also a } where there should be a )
Hint: You can enter the angle brackets using the html for them - i.e < is "& lt;" (andLessThanSemicolon)
and > = "& gt;" (andGreaterThanSemicolon)
Note: You just need to remove the space after the & character.
modified 15-Apr-12 15:16pm.
|
|
|
|
|
I know about angle brackets :: I used angle brackets first, but the editor treated the texts between the angle brackets as HTML codes and dropped them, and I was in a hurry, so I quickly cut-and-pasted it to Wordpad and changed the brackets. Sorry.
Please, after the usual #include's:-
#include .......
FILE *F;
is there something like this that I could write to set and get a file's text caption?
setfilecaption(F,"Hardhat diver in Albert Dock, Liverpool");
getfilecaption(F,s,n); /* get file F's caption into string s, allow n bytes for it. */
~~~~~~~~~~~~~~~~
Are these captions stored within the file descriptor, like the last-modified date and suchike, or are they stored in the Windows registry?
|
|
|
|
|
There's been no problem caused through your use of brackets.
No, there isn't something available with the interface you describe. The provided functions are available in .NET
See here: reading-writing-and-photo-metadata[^]
Furthermore, the data is stored in neither the directory entry (fileDescriptor) nor the Registry. See for yourself!
Got a Hex-Editor? (Nope? Get one - HxD is okay and $free)
I chose a JPG and did the following:
1) Right-click a photo
2) Select Properties, then the Details tab.
3) Add some unique text - I set the Camera Model field to "Canon EOS".
4) Hit apply
5) Now you can see that the photo's last modified date is the current date and time, furthermore, when you open the image in the HexEditor, you can easily find the text you entered.
It should be fairly easy to implement the getfilecaption function yourself, it's likely going to involve searching the file for some kind of marker (don't think you'll have to parse the whole file, including image data yourself) so that you know where the metadata starts.
Obviously, different filetypes have different structures, so you'd have to implement the function for each of the different image-file types you'd like to support.
Unfortunately, it is unlikely that writing the metadata will be so simple.
Here's a few pertinant links:
JFIF metadata[^]
(2nd search result): Does Exif metadata always get stored just after the jfif header?[^]
|
|
|
|
|
|
Hey again,
I was just doing some stuff with GDI+ the other night when I came across the functions available in gdi+ that would do this. Then sometime last night I recalled this thread.
Seems you don't need to be tied to using .NET, you can just use GDI+
It seems a little messy, though these pages should help you:
Reading and Writing Metadata[^]
EDIT:
#include <gdiplus.h> // needs gdiplus.lib
#include <gdiplus/Gdiplusimaging.h> // contains tag names and ids
using namespace Gdiplus;
void onTestButton()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
UINT count = 0;
Image* image = new Image(L"test.jpg");
count = image->GetPropertyCount();
if(count == 0)
return;
PROPID* propIDs = new PROPID[count];
image->GetPropertyIdList(count, propIDs);
for(UINT j = 0; j < count; ++j)
{
int size;
long *longPtr; PropertyItem* propertyItem = NULL;
size = image->GetPropertyItemSize(propIDs[j]);
propertyItem = (PropertyItem*)malloc(size);
image->GetPropertyItem(propIDs[j], size, propertyItem);
if(propertyItem->type == PropertyTagTypeASCII)
{
printf("prop tag id: 0x%04X, (string) - value is: %s.\n", propIDs[j], propertyItem->value);
}
if(propertyItem->type == PropertyTagTypeLong)
{
longPtr = (long*) propertyItem->value;
printf("prop tag id: 0x%04X, (long) - value is: %d.\n", propIDs[j], *longPtr);
}
free(propertyItem);
}
delete [] propIDs;
delete image;
GdiplusShutdown(gdiplusToken);
}
Output:
prop tag id: 0x010E, (string) - value is: Title.
prop tag id: 0x0131, (string) - value is: GIMP 2.6.8.
prop tag id: 0x0132, (string) - value is: 2012:04:15 10:25:45.
prop tag id: 0x013B, (string) - value is: Author.
prop tag id: 0x8298, (string) - value is: Copyright (c).
prop tag id: 0xA002, (long) - value is: 154.
prop tag id: 0xA003, (long) - value is: 205.
prop tag id: 0x0201, (long) - value is: 14382.
prop tag id: 0x0202, (long) - value is: 4631.
modified 4-May-12 15:10pm.
|
|
|
|
|
This is my code:
#include "stdafx.h"
#include <windows.h>
#include <glut.h>
#include <glaux.h>
#pragma comment(lib,"opengl32.lib")
#pragma comment(lib,"glaux.lib")
LRESULT CALLBACK WindowProc(HWND,UINT,WPARAM,LPARAM);
void EnableOpenGL(HWND hwnd,HDC* ,HGLRC*);
void DisableOpenGL(HWND,HDC,HGLRC);
int APIENTRY WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR nCmdLine,
int nCmdShow)
{
WNDCLASSEX wcex;
HWND hwnd;
HDC hDC;
HGLRC hRC;
MSG msg;
BOOL bQuit=FALSE;
float i=0.0f,Angle=0.0f;
wcex.cbSize=sizeof(WNDCLASSEX);
wcex.cbClsExtra=0;
wcex.cbWndExtra=0;
wcex.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.hCursor=LoadCursor(NULL,IDC_CROSS);
wcex.hIcon=LoadIcon(NULL,IDI_INFORMATION);
wcex.hIconSm=NULL;
wcex.hInstance=hInstance;
wcex.lpfnWndProc=WindowProc;
wcex.lpszClassName="OpenGL___Xiang";
wcex.lpszMenuName=NULL;
wcex.style=CS_HREDRAW|CS_VREDRAW;
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,"注册类失败!","Error",MB_ICONERROR);
return 0;
}
hwnd=CreateWindowEx(0,
"OpenGL___Xiang","OpenGL Sample",WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,0);
ShowWindow(hwnd,SW_MAXIMIZE);
EnableOpenGL(hwnd,&hDC,&hRC);
while (!bQuit)
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message==WM_QUIT)
{
bQuit=TRUE;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
glClearColor(0.0f,0.0f,0.0f,0.5f);
glClearDepth(1.0f);
glEnable(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
glPushMatrix();
glTranslatef(0.0f,0.0f,0.0f);
glColor3f(0.0f,1.0f,0.0f);
for (i=-50;i<=50;i+=1)
{
glBegin(GL_LINES);
glVertex3f( -50,0,i);
glVertex3f( 50,0,i);
glVertex3f( i,0,-50);
glVertex3f( i,0,50);
glEnd();
}
glPopMatrix();
SwapBuffers(hDC);
}
}
DisableOpenGL(hwnd,hDC,hRC);
DestroyWindow(hwnd);
return msg.wParam;
}
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
switch (msg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_KEYDOWN:
{
switch (wparam)
{
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
}
break;
default:
return DefWindowProc(hwnd,msg,wparam,lparam);
}
return 0;
}
void EnableOpenGL(HWND hwnd,HDC* hDC,HGLRC* hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int iFormat;
*hDC=GetDC(hwnd);
ZeroMemory(&pfd,sizeof(pfd));
pfd.nSize=sizeof(pfd);
pfd.nVersion=1;
pfd.dwFlags=PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER;
pfd.iPixelType=PFD_TYPE_RGBA;
pfd.cColorBits=24;
pfd.cDepthBits=16;
pfd.iLayerType=PFD_MAIN_PLANE; iFormat=ChoosePixelFormat(*hDC,&pfd);
SetPixelFormat(*hDC,iFormat,&pfd);
*hRC=wglCreateContext(*hDC);
wglMakeCurrent(*hDC,*hRC);
}
void DisableOpenGL(HWND hwnd,HDC hdc,HGLRC hRC)
{
wglMakeCurrent(NULL,NULL);
wglDeleteContext(hRC);
ReleaseDC(hwnd,hdc);
}
|
|
|
|
|
Well, your program is operating in ORTHO mode (No perspective)
Therefore, changing the object's Z position while maintaining the object's X,Y position will not result in a different position on screen.
You are indeed drawing 100 lines(actually, 100 quads - with outline only style), they're all drawn on top of each other!
Try to substitute this for your own loop:
for (i=0;i<50;i++)
{
glBegin(GL_LINES);
glVertex3f( -1,(i*0.02)-0.5,1);
glVertex3f( 1,(i*0.02)-0.5,1);
glVertex3f( -1,(i*0.02)-0.5,1);
glVertex3f( 1,(i*0.02)-0.5,1);
glEnd();
}
You may wish to search for "OpenGL Viewing Transformation Matrix", for more discussion on the topic. gldPerspective and glvPerspective are functions I've used in the past, though they rely on glut - you've included it, however your code is typical of that wishing to avoid the use of GLUT.
Here's the functions I use for perspective:
void gldPerspective(GLdouble fovx, GLdouble aspect, GLdouble zNear, GLdouble zFar)
{
GLdouble xmin, xmax, ymin, ymax;
GLdouble m[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
xmax = zNear * tan(fovx * M_PI / 360.0);
xmin = -xmax;
ymin = xmin / aspect;
ymax = xmax / aspect;
m[0] = (2.0 * zNear) / (xmax - xmin);
m[5] = (2.0 * zNear) / (ymax - ymin);
m[10] = -(zFar + zNear) / (zFar - zNear);
m[2] = (xmax + xmin) / (xmax - xmin);
m[6] = (ymax + ymin) / (ymax - ymin);
m[11] = -1.0;
m[14] = -(2.0 * zFar * zNear) / (zFar - zNear);
glMatrixMode(GL_PROJECTION);
glMultMatrixd(m);
}
void glvPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
{
GLdouble xmin, xmax, ymin, ymax;
GLdouble m[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
xmax = zNear * tan(fovy * M_PI / 360.0);
xmin = -xmax;
ymin = xmin / aspect;
ymax = xmax / aspect;
m[0] = (2 * zNear) / (xmax - xmin);
m[5] = (2 * zNear) / (ymax - ymin);
m[10]= -(zFar + zNear) / (zFar - zNear);
m[2] = (xmax + xmin) / (xmax - xmin);
m[6] = (ymax + ymin) / (ymax - ymin);
m[11] = -aspect;
m[14] = -(2 * zFar * zNear) / (zFar - zNear);
glMatrixMode(GL_PROJECTION);
glMultMatrixd(m);
}
|
|
|
|
|
hi all,
progress bar control not working well with larger than 2147483647 value.
can anybody please assist me how can i use Progress bar with larger values
thanks in advance.
|
|
|
|
|
Since the range is an int and that is the max value of an int then you would have to either subclass the progress bar to take a different kind of range or find one that will do what you want.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|