Abrir DialogBox en vs2015 C++ x64 WinAPI

Este es el componente que buscaremos abrir en éste tutorial, es muy sencillo pero suele marcar errores al cambiar de x86 a x64

El codigo fue probado en el siguiente entorno: Release x64 y Debug x64


 

Paso 1 – Crear el DialogBox: ésta parte es exactamente igual que en otras versiones solamente se da clic derecho en «Archivos de recurso y se elige la opción de Dialog»

Elegimos «Dialog» solamente, NO ELEGIR los que vienen dentro de ésta opción


Paso 2 – Fijar el ID del DialogBox: ésta parte también es igual que en otras versiones, solamente nos vamos a la ventana de propiedades y cambiamos el ID, el ID que usaremos para este ejemplo sera «DBX_TEST»

Paso 3 – Crear la variable de instancia y el prototipo del callback para nuestro dialogo, aqui cambia solo el tipo de variable para el callback, ya que antes se usaba «BOOL» y ahora se cambia a «LRESULT»

Los que usaremos para éste ejemplo serán:

  • HINSTANCE dbx_dialogo1;
  • LRESULT CALLBACK call_dialog1(HWND, UINT, WPARAM, LPARAM);

Agregarlos sobre el main del codigo principal

Paso 4 – Crear el callback como función para poner los eventos

LRESULT CALLBACK call_dialog1(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
 switch (msg)
 {
 case WM_COMMAND:
 {
 switch (LOWORD(wParam))
 {
 case IDOK:
 start();
 break;
 }
 } 
 break;
 }
 return false;
}

Este callback tiene funcionamiento básico, cuando se le da click al boton «IDOK» se manda a llamar la función start

Paso 5 – Abrir DialogBox: ahora si, esta opción es la que cambió, aunque solamente un poco, se debe agregar primero el casteo utilizando reinterpret_cast<DLGPROC>() de la siguiente forma:

DialogBox(dbx_dialogo1, MAKEINTRESOURCE(DBX_TEST), hWnd, 
 reinterpret_cast<DLGPROC>(call_dialog1));

Y ya sería todo, con ese codigo ya se pueden abrir DialogBox con eventos en x64

También te podría gustar...

9 Respuestas

  1. Thanks for one’s marvelous posting! I truly enjoyed reading it, you could be a great author. I will ensure that I bookmark your blog and may come back later on. I want to encourage yourself to continue your great work, have a nice afternoon!

  2. Thanks for sharing superb informations. Your website is so cool. I am impressed by the details that you have on this site. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for extra articles. You, my pal, ROCK! I found simply the information I already searched all over the place and just could not come across. What a great web site.

  3. If you are going for best contents like I do, just pay a visit this site daily as it presents feature contents, thanks

  4. As I website owner I think the subject material here is real superb, thanks for your efforts.

  5. Thanks so much for providing individuals with remarkably superb possiblity to read from this site. It’s usually very superb and also packed with a great time for me personally and my office mates to visit the blog at least 3 times in 7 days to read through the newest things you have. And definitely, we are at all times contented considering the brilliant principles served by you. Certain 3 ideas in this post are indeed the most beneficial we have all ever had.

  6. anitamcinnis dice:

    Can I simply just say what a relief to discover somebody that actually understands what they’re talking about on the net. You actually understand how to bring an issue to light and make it important. A lot more people should look at this and understand this side of your story. I was surprised that you’re not more popular since you surely have the gift.

  7. anitamcinnis dice:

    Great delivery. Great arguments. Keep up the amazing spirit.

  8. ouidapanton dice:

    I could not refrain from commenting. Exceptionally well written!

  9. Excellent blog you have here.. It’s hard to find high-quality writing like yours these days. I seriously appreciate people like you! Take care!!

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *